Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4597)

Unified Diff: chrome/browser/bookmarks/bookmark_html_writer.cc

Issue 2063863002: Use DCHECKs when observing only a single notification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/bookmarks/bookmark_html_writer.cc
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc
index c95e150b0f8b0a6b7ee183a3e1f7b4301914a978..df55855046e679d38934e18993c7eb0cf1a6e3bc 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer.cc
@@ -42,7 +42,7 @@ using content::BrowserThread;
namespace {
-static BookmarkFaviconFetcher* fetcher = NULL;
+BookmarkFaviconFetcher* g_fetcher = nullptr;
// File header.
const char kHeader[] =
@@ -423,9 +423,10 @@ void BookmarkFaviconFetcher::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- if (chrome::NOTIFICATION_PROFILE_DESTROYED == type && fetcher != NULL) {
- base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, fetcher);
- fetcher = NULL;
+ DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
+ if (g_fetcher) {
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, g_fetcher);
+ g_fetcher = nullptr;
}
}
@@ -451,9 +452,9 @@ void BookmarkFaviconFetcher::ExecuteWriter() {
new Writer(codec.Encode(BookmarkModelFactory::GetForProfile(
profile_)),
path_, favicons_map_.release(), observer_)));
- if (fetcher != NULL) {
- base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, fetcher);
- fetcher = NULL;
+ if (g_fetcher) {
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, g_fetcher);
+ g_fetcher = nullptr;
}
}
@@ -510,9 +511,9 @@ void WriteBookmarks(Profile* profile,
// BookmarkModel isn't thread safe (nor would we want to lock it down
// for the duration of the write), as such we make a copy of the
// BookmarkModel using BookmarkCodec then write from that.
- if (fetcher == NULL) {
- fetcher = new BookmarkFaviconFetcher(profile, path, observer);
- fetcher->ExportBookmarks();
+ if (!g_fetcher) {
+ g_fetcher = new BookmarkFaviconFetcher(profile, path, observer);
+ g_fetcher->ExportBookmarks();
}
}
« no previous file with comments | « chrome/browser/background/background_mode_manager.cc ('k') | chrome/browser/chromeos/app_mode/startup_app_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698