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

Unified Diff: chrome/browser/jumplist_listener.cc

Issue 11515005: Delay updating jumplist to avoid blocking the file thread at start-up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add JumpListListener Created 8 years 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/jumplist_listener.cc
diff --git a/chrome/browser/jumplist_listener.cc b/chrome/browser/jumplist_listener.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dd7b83c0de6bbc278f3c226d83ebff4f12c2da72
--- /dev/null
+++ b/chrome/browser/jumplist_listener.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/jumplist_listener.h"
+
+#include <string>
+#include <vector>
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback_forward.h"
+#include "chrome/browser/jumplist_win.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_source.h"
+#include "content/public/browser/notification_types.h"
+
+
sky 2012/12/18 20:52:38 Only one newline.
Cait (Slow) 2012/12/19 19:27:01 Done.
+JumpListListener::JumpListListener(base::Closure callback)
+ : callback_(callback),
+ called_(false) {
+ registrar_.reset(new content::NotificationRegistrar);
+ // Register for notification of when initial page load is complete to ensure
+ // that we wait until start-up is complete before calling the callback.
+ registrar_->Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
+ content::NotificationService::AllSources());
+}
+
+JumpListListener::~JumpListListener() {
+}
+
+void JumpListListener::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ switch (type) {
+ case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: {
+ if (!called_) {
+ called_ = true;
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE, callback_);
sky 2012/12/18 20:52:38 Why the delay?
Cait (Slow) 2012/12/19 19:27:01 Done.
+ }
+ break;
+ }
+ default:
+ NOTREACHED() << "Unexpected notification type.";
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698