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

Unified Diff: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc

Issue 168253002: Cleanup many APIs to use ProfileKeyedAPI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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/extensions/api/bluetooth/bluetooth_api.cc
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
index b6cf1660dd3c0d2da3edb0c5f8d8b9270a5b7257..42a51a375869ce2207c84fdbc725721e5b25f4f2 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
@@ -6,8 +6,8 @@
#include <string>
+#include "base/lazy_instance.h"
#include "base/memory/ref_counted.h"
-#include "chrome/browser/extensions/api/bluetooth/bluetooth_api_factory.h"
#include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h"
#include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h"
#include "chrome/browser/extensions/event_names.h"
@@ -27,6 +27,7 @@
#include "extensions/common/permissions/permissions_data.h"
#include "net/base/io_buffer.h"
+using content::BrowserContext;
using device::BluetoothAdapter;
using device::BluetoothDevice;
using device::BluetoothProfile;
@@ -35,8 +36,9 @@ using device::BluetoothSocket;
namespace {
-extensions::ExtensionBluetoothEventRouter* GetEventRouter(Profile* profile) {
- return extensions::BluetoothAPI::Get(profile)->bluetooth_event_router();
+extensions::ExtensionBluetoothEventRouter* GetEventRouter(
+ BrowserContext* context) {
+ return extensions::BluetoothAPI::Get(context)->bluetooth_event_router();
}
} // namespace
@@ -77,12 +79,21 @@ namespace Write = extensions::api::bluetooth::Write;
namespace extensions {
+static base::LazyInstance<ProfileKeyedAPIFactory<BluetoothAPI> > g_factory =
+ LAZY_INSTANCE_INITIALIZER;
+
+// static
+ProfileKeyedAPIFactory<BluetoothAPI>* BluetoothAPI::GetFactoryInstance() {
+ return g_factory.Pointer();
+}
+
// static
-BluetoothAPI* BluetoothAPI::Get(Profile* profile) {
- return BluetoothAPIFactory::GetForProfile(profile);
+BluetoothAPI* BluetoothAPI::Get(BrowserContext* context) {
+ return GetFactoryInstance()->GetForProfile(context);
}
-BluetoothAPI::BluetoothAPI(Profile* profile) : profile_(profile) {
+BluetoothAPI::BluetoothAPI(BrowserContext* context)
+ : profile_(Profile::FromBrowserContext(context)) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
this, bluetooth::OnAdapterStateChanged::kEventName);
}

Powered by Google App Engine
This is Rietveld 408576698