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

Unified Diff: chrome/browser/ui/views/load_complete_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: rebase Created 7 years, 12 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/ui/views/load_complete_listener.cc
diff --git a/chrome/browser/ui/views/load_complete_listener.cc b/chrome/browser/ui/views/load_complete_listener.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2dde948f52ee2b552599c2566c64aaecbd307dcb
--- /dev/null
+++ b/chrome/browser/ui/views/load_complete_listener.cc
@@ -0,0 +1,44 @@
+// 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/ui/views/load_complete_listener.h"
+
+#include "chrome/common/chrome_notification_types.h"
tfarina 2013/01/09 23:58:24 this include is not necessary as you already inclu
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_source.h"
+#include "content/public/browser/notification_types.h"
+
+LoadCompleteListener::LoadCompleteListener(Delegate* delegate)
+ : delegate_(delegate) {
+ registrar_ = new content::NotificationRegistrar();
tfarina 2013/01/09 23:58:24 You are leaking this, as far as I can see. You sho
+ // 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());
+}
+
+LoadCompleteListener::~LoadCompleteListener() {
+ if (registrar_ && registrar_->IsRegistered(this,
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
tfarina 2013/01/09 23:58:24 indent just 4 spaces after 'if'.
+ content::NotificationService::AllSources())) {
+ registrar_->Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
+ content::NotificationService::AllSources());
+ }
+}
+
+void LoadCompleteListener::Observe(int type,
+ const content::NotificationSource& source,
tfarina 2013/01/09 23:58:24 wrong indentation here.
+ const content::NotificationDetails& details) {
+ switch (type) {
+ case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: {
+ delegate_->OnLoadCompleted();
+ registrar_->Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
+ content::NotificationService::AllSources());
+ break;
+ }
+ default:
+ NOTREACHED() << "Unexpected notification type.";
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698