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

Unified Diff: content/browser/bluetooth/bluetooth_dispatcher_host.h

Issue 1286063002: Add a path for content/ to open and control a Bluetooth chooser dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Fix comment wrapping. Created 5 years, 4 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
« no previous file with comments | « content/browser/bad_message.h ('k') | content/browser/bluetooth/bluetooth_dispatcher_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/bluetooth/bluetooth_dispatcher_host.h
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.h b/content/browser/bluetooth/bluetooth_dispatcher_host.h
index e0c92f74df913f5549fffddee167bf7fb67d11dc..8dfee761acaf7410161785429fe57815228eac9a 100644
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.h
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.h
@@ -6,7 +6,9 @@
#define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_
#include "base/basictypes.h"
+#include "base/id_map.h"
#include "base/memory/weak_ptr.h"
+#include "content/public/browser/bluetooth_chooser.h"
#include "content/public/browser/browser_message_filter.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_gatt_connection.h"
@@ -57,6 +59,16 @@ class CONTENT_EXPORT BluetoothDispatcherHost final
// releasing references to previous |adapter_|.
void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter);
+ // Stops all BluetoothDiscoverySessions being run for requestDevice()
+ // choosers.
+ void StopDeviceDiscovery();
+
+ // BluetoothAdapter::Observer:
+ void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
+ bool powered) override;
+ void DeviceAdded(device::BluetoothAdapter* adapter,
+ device::BluetoothDevice* device) override;
+
// IPC Handlers, see definitions in bluetooth_messages.h.
void OnRequestDevice(
int thread_id,
@@ -84,20 +96,21 @@ class CONTENT_EXPORT BluetoothDispatcherHost final
// Callbacks for BluetoothAdapter::StartDiscoverySession.
void OnDiscoverySessionStarted(
- int thread_id,
- int request_id,
+ int chooser_id,
scoped_ptr<device::BluetoothDiscoverySession> discovery_session);
- void OnDiscoverySessionStartedError(int thread_id, int request_id);
+ void OnDiscoverySessionStartedError(int chooser_id);
- // Stop in progress discovery session.
- void StopDiscoverySession(
- int thread_id,
- int request_id,
- scoped_ptr<device::BluetoothDiscoverySession> discovery_session);
+ // BluetoothChooser::EventHandler:
+ void OnBluetoothChooserEvent(int chooser_id,
+ BluetoothChooser::Event event,
+ const std::string& device_id);
- // Callbacks for BluetoothDiscoverySession::Stop.
- void OnDiscoverySessionStopped(int thread_id, int request_id);
- void OnDiscoverySessionStoppedError(int thread_id, int request_id);
+ // The chooser implementation yields to the event loop to avoid re-entering
+ // code that's still using the RequestDeviceSession, and continues with this
+ // function.
+ void FinishClosingChooser(int chooser_id,
+ BluetoothChooser::Event event,
+ const std::string& device_id);
// Callbacks for BluetoothDevice::CreateGattConnection.
void OnGATTConnectionCreated(
@@ -142,7 +155,7 @@ class CONTENT_EXPORT BluetoothDispatcherHost final
// including the chooser dialog.
// An entry is added to this map in OnRequestDevice, and should be removed
// again everywhere a requestDevice() reply is sent.
- std::map<std::pair<int, int>, RequestDeviceSession> request_device_sessions_;
+ IDMap<RequestDeviceSession, IDMapOwnPointer> request_device_sessions_;
// Maps to get the object's parent based on it's instanceID
// Map of service_instance_id to device_instance_id.
@@ -156,6 +169,13 @@ class CONTENT_EXPORT BluetoothDispatcherHost final
// A BluetoothAdapter instance representing an adapter of the system.
scoped_refptr<device::BluetoothAdapter> adapter_;
+ // Automatically stops Bluetooth discovery a set amount of time after it was
+ // started. We have a single timer for all of Web Bluetooth because it's
+ // simpler than tracking timeouts for each RequestDeviceSession individually,
+ // and because there's no harm in extending the length of a few discovery
+ // sessions when other sessions are active.
+ base::Timer discovery_session_timer_;
+
// Must be last member, see base/memory/weak_ptr.h documentation
base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_;
« no previous file with comments | « content/browser/bad_message.h ('k') | content/browser/bluetooth/bluetooth_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698