Skip to content

Commit

Permalink
[iOS] - Replace NOTREACHED_IN_MIGRATION for iOS (#26224)
Browse files Browse the repository at this point in the history
* Remove NOTREACHED_IN_MIGRATION for iOS. Replaced with CHECK, DCHECK, [[no_return]] where necessary.
  • Loading branch information
Brandon-T authored Oct 25, 2024
1 parent 9964975 commit 9a7a73b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 35 deletions.
2 changes: 1 addition & 1 deletion ios/browser/api/bookmarks/bookmark_model_listener_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ - (instancetype)initWithNode:(const bookmarks::BookmarkNode*)node
void BookmarkModelListener::BookmarkModelBeingDeleted() {
// This is an inconsistent state in the application lifecycle. The bookmark
// model shouldn't disappear.
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}

void BookmarkModelListener::BookmarkNodeMoved(
Expand Down
26 changes: 7 additions & 19 deletions ios/browser/api/bookmarks/exporter/bookmark_html_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> {
break;

default:
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}

return Write(utf8_string);
Expand All @@ -327,20 +327,14 @@ class Writer : public base::RefCountedThreadSafe<Writer> {
const std::string* date_added_string =
value.FindString(BookmarkCodec::kDateAddedKey);
const std::string* type_string = value.FindString(BookmarkCodec::kTypeKey);
if (!title_ptr || !date_added_string || !type_string ||
(*type_string != BookmarkCodec::kTypeURL &&
*type_string != BookmarkCodec::kTypeFolder)) {
NOTREACHED_IN_MIGRATION();
return false;
}
CHECK(title_ptr && date_added_string && type_string &&
(*type_string == BookmarkCodec::kTypeURL ||
*type_string == BookmarkCodec::kTypeFolder));

std::string title = *title_ptr;
if (*type_string == BookmarkCodec::kTypeURL) {
const std::string* url_string = value.FindString(BookmarkCodec::kURLKey);
if (!url_string) {
NOTREACHED_IN_MIGRATION();
return false;
}
CHECK(url_string);

std::string favicon_string;
auto itr = favicons_map_->find(*url_string);
Expand Down Expand Up @@ -368,10 +362,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> {
value.FindString(BookmarkCodec::kDateModifiedKey);
const base::Value::List* child_values =
value.FindList(BookmarkCodec::kChildrenKey);
if (!last_modified_date || !child_values) {
NOTREACHED_IN_MIGRATION();
return false;
}
CHECK(last_modified_date && child_values);
if (folder_type != BookmarkNode::OTHER_NODE &&
folder_type != BookmarkNode::MOBILE) {
// The other/mobile folder name are not written out. This gives the effect
Expand All @@ -398,10 +389,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> {

// Write the children.
for (const base::Value& child_value : *child_values) {
if (!child_value.is_dict()) {
NOTREACHED_IN_MIGRATION();
return false;
}
CHECK(child_value.is_dict());
if (!WriteNode(child_value.GetDict(), BookmarkNode::FOLDER)) {
return false;
}
Expand Down
15 changes: 10 additions & 5 deletions ios/browser/api/bookmarks/exporter/brave_bookmarks_exporter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,20 @@
void BraveBookmarksExportObserver::OnExportFinished(Result result) {
switch (result) {
case Result::kSuccess:
return _on_export_finished(BraveBookmarksExporterStateCompleted);
_on_export_finished(BraveBookmarksExporterStateCompleted);
break;
case Result::kCouldNotCreateFile:
return _on_export_finished(BraveBookmarksExporterStateErrorCreatingFile);
_on_export_finished(BraveBookmarksExporterStateErrorCreatingFile);
break;
case Result::kCouldNotWriteHeader:
return _on_export_finished(BraveBookmarksExporterStateErrorWritingHeader);
_on_export_finished(BraveBookmarksExporterStateErrorWritingHeader);
break;
case Result::kCouldNotWriteNodes:
return _on_export_finished(BraveBookmarksExporterStateErrorWritingNodes);
_on_export_finished(BraveBookmarksExporterStateErrorWritingNodes);
break;
default:
NOTREACHED_IN_MIGRATION();
delete this;
NOTREACHED();
}
delete this;
}
Expand Down
6 changes: 2 additions & 4 deletions ios/browser/api/bookmarks/importer/bookmark_html_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,8 @@ void ImportBookmarksFile(
if (is_bookmark &&
post_data.empty() &&
(valid_url_callback.is_null() || valid_url_callback.Run(url))) {
if (toolbar_folder_index > path.size() && !path.empty()) {
NOTREACHED_IN_MIGRATION(); // error in parsing.
break;
}
CHECK(toolbar_folder_index <= path.size() ||
path.empty()); // error in parsing.

ImportedBookmarkEntry entry;
entry.creation_time = add_date;
Expand Down
9 changes: 5 additions & 4 deletions ios/browser/api/bookmarks/importer/bookmarks_importer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,20 @@
}

// If the given name is unique, use it.
if (existing_folder_names.find(folder_name) == existing_folder_names.end())
if (existing_folder_names.find(folder_name) == existing_folder_names.end()) {
return folder_name;
}

// Otherwise iterate until we find a unique name.
for (size_t i = 1; i <= existing_folder_names.size(); ++i) {
std::u16string name =
folder_name + u" (" + base::NumberToString16(i) + u")";
if (existing_folder_names.find(name) == existing_folder_names.end())
if (existing_folder_names.find(name) == existing_folder_names.end()) {
return name;
}
}

NOTREACHED_IN_MIGRATION();
return folder_name;
NOTREACHED();
}

// Shows the bookmarks toolbar.
Expand Down
2 changes: 1 addition & 1 deletion ios/browser/api/web/ui/chrome_webview.mm
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ - (void)webStateDestroyed:(web::WebState*)webState {
// The WebState is owned by the current instance, and the observer bridge
// is unregistered before the WebState is destroyed, so this event should
// never happen.
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}

// MARK: - CRWWebStateDelegate implementation
Expand Down
3 changes: 2 additions & 1 deletion ios/browser/favicon/brave_ios_web_favicon_driver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
void BraveIOSWebFaviconDriver::DownloadManifest(
const GURL& url,
ManifestDownloadCallback callback) {
NOTREACHED_IN_MIGRATION();
// We don't support downloading manifests
NOTREACHED();
}

bool BraveIOSWebFaviconDriver::IsOffTheRecord() {
Expand Down

0 comments on commit 9a7a73b

Please sign in to comment.