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

Unified Diff: chrome/browser/extensions/bluetooth_event_router.h

Issue 11360200: Decouple bluetooth_event_router from extension_system. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removed MockBluetoothSocket 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/bluetooth_event_router.h
diff --git a/chrome/browser/extensions/bluetooth_event_router.h b/chrome/browser/extensions/bluetooth_event_router.h
deleted file mode 100644
index 657053879190b2520ae6f936a4d4e8c665fa1105..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/bluetooth_event_router.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// 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_BLUETOOTH_EVENT_ROUTER_H_
-#define CHROME_BROWSER_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_
-
-#include <map>
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_vector.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/extensions/api/bluetooth.h"
-#include "device/bluetooth/bluetooth_adapter.h"
-#include "device/bluetooth/bluetooth_socket.h"
-
-namespace extensions {
-
-class ExtensionBluetoothEventRouter
- : public device::BluetoothAdapter::Observer {
- public:
- explicit ExtensionBluetoothEventRouter(Profile* profile);
- virtual ~ExtensionBluetoothEventRouter();
-
- // adapter() will return NULL if the bluetooth adapter is not supported in the
- // current platform.
- const device::BluetoothAdapter* adapter() const {
- return adapter_.get();
- }
-
- // GetMutableAdapter will return NULL if the bluetooth adapter is not
- // supported in the current platform.
- device::BluetoothAdapter* GetMutableAdapter() {
- return adapter_.get();
- }
-
- // Register the BluetoothSocket |socket| for use by the extensions system.
- // This class will hold onto the socket for its lifetime, or until
- // ReleaseSocket is called for the socket. Returns an id for the socket.
- int RegisterSocket(scoped_refptr<device::BluetoothSocket> socket);
-
- // Release the BluetoothSocket corresponding to |id|. Returns true if
- // the socket was found and released, false otherwise.
- bool ReleaseSocket(int id);
-
- // Get the BluetoothSocket corresponding to |id|.
- scoped_refptr<device::BluetoothSocket> GetSocket(int id);
-
- // Sets whether this Profile is responsible for the discovering state of the
- // adapter.
- void SetResponsibleForDiscovery(bool responsible);
- bool IsResponsibleForDiscovery() const;
-
- // Sets whether or not DeviceAdded events will be dispatched to extensions.
- void SetSendDiscoveryEvents(bool should_send);
-
- // Dispatch an event that takes a device as a parameter to all renderers.
- void DispatchDeviceEvent(
- const char* event_name,
- const extensions::api::bluetooth::Device& device);
-
- // Override from device::BluetoothAdapter::Observer
- virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter,
- bool present) OVERRIDE;
- virtual void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
- bool has_power) OVERRIDE;
- virtual void AdapterDiscoveringChanged(device::BluetoothAdapter* adapter,
- bool discovering) OVERRIDE;
- virtual void DeviceAdded(device::BluetoothAdapter* adapter,
- device::BluetoothDevice* device) OVERRIDE;
-
- // Exposed for testing.
- void SetAdapterForTest(device::BluetoothAdapter* adapter) {
- adapter_ = adapter;
- }
- private:
- void DispatchBooleanValueEvent(const char* event_name, bool value);
-
- bool send_discovery_events_;
- bool responsible_for_discovery_;
-
- Profile* profile_;
- scoped_refptr<device::BluetoothAdapter> adapter_;
-
- // The next id to use for referring to a BluetoothSocket. We avoid using
- // the fd of the socket because we don't want to leak that information to
- // the extension javascript.
- int next_socket_id_;
-
- typedef std::map<int, scoped_refptr<device::BluetoothSocket> > SocketMap;
- SocketMap socket_map_;
-
- typedef ScopedVector<extensions::api::bluetooth::Device>
- DeviceList;
- DeviceList discovered_devices_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothEventRouter);
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_

Powered by Google App Engine
This is Rietveld 408576698