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

Unified Diff: chrome/browser/extensions/api/processes/processes_api_service.h

Issue 11359081: Lazy initialization for ProcessesEventRouter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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/extensions/api/processes/processes_api_service.h
diff --git a/chrome/browser/extensions/api/processes/processes_api_service.h b/chrome/browser/extensions/api/processes/processes_api_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..b7c593f57a562f3c7ed41d5d2b18a21f0bc03df0
--- /dev/null
+++ b/chrome/browser/extensions/api/processes/processes_api_service.h
@@ -0,0 +1,46 @@
+// 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.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_SERVICE_H__
+#define CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_SERVICE_H__
+
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/extensions/event_router.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+
+class Profile;
+
+namespace extensions {
Aaron Boodman 2012/11/07 04:08:20 Nit: In the end, I don't think we want these in th
Yoyo Zhou 2012/11/07 22:53:36 Should they be in a namespace like processes_api?
Aaron Boodman 2012/11/07 23:51:28 I think it depends on whether they end up being th
+class ProcessesEventRouter;
+
+// The profile-keyed service that manages the processes extension API.
+class ProcessesAPIService : public ProfileKeyedService,
+ public EventRouter::Observer {
+ public:
+ explicit ProcessesAPIService(Profile* profile);
+ virtual ~ProcessesAPIService();
+
+ // Convenience method to get the ProcessesAPIService for a profile.
+ static ProcessesAPIService* Get(Profile* profile);
+
+ ProcessesEventRouter* processes_event_router() {
+ return processes_event_router_.get();
+ }
+
+ // EventRouter::Observer implementation.
+ virtual void OnListenerAdded(const std::string& event_name) OVERRIDE;
+ virtual void OnListenerRemoved(const std::string& event_name) OVERRIDE;
+
+ private:
+ Profile* profile_;
+
+ // Lazily initialized in OnListenerAdded.
+ scoped_ptr<extensions::ProcessesEventRouter> processes_event_router_;
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_SERVICE_H__

Powered by Google App Engine
This is Rietveld 408576698