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

Side by Side Diff: content/renderer/bluetooth/bluetooth_dispatcher.h

Issue 1922923002: bluetooth: Move requestDevice to mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-separate-tests-request-device
Patch Set: Change ref to pointer Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/bluetooth/bluetooth_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_
6 #define CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_
7
8 #include <stdint.h>
9
10 #include <map>
11 #include <queue>
12
13 #include "base/id_map.h"
14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h"
16 #include "content/common/bluetooth/bluetooth_device.h"
17 #include "content/public/child/worker_thread.h"
18 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetooth.h"
19 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothError .h"
20
21 namespace base {
22 class MessageLoop;
23 class TaskRunner;
24 }
25
26 namespace IPC {
27 class Message;
28 }
29
30 namespace content {
31 class ThreadSafeSender;
32
33 // Dispatcher for child process threads which communicates to the browser's
34 // BluetoothDispatcherHost.
35 //
36 // Instances are created for each thread as necessary by WebBluetoothImpl.
37 //
38 // Incoming IPC messages are received by the BluetoothMessageFilter and
39 // directed to the thread specific instance of this class.
40 // Outgoing messages come from WebBluetoothImpl.
41 class BluetoothDispatcher : public WorkerThread::Observer {
42 public:
43 explicit BluetoothDispatcher(ThreadSafeSender* sender);
44 ~BluetoothDispatcher() override;
45
46 // Gets or Creates a BluetoothDispatcher for the current thread.
47 // |thread_safe_sender| is required when constructing a BluetoothDispatcher.
48 static BluetoothDispatcher* GetOrCreateThreadSpecificInstance(
49 ThreadSafeSender* thread_safe_sender);
50
51 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener.
52 bool Send(IPC::Message* msg);
53 void OnMessageReceived(const IPC::Message& msg);
54
55 // Corresponding to WebBluetoothImpl methods.
56 void requestDevice(int frame_routing_id,
57 const blink::WebRequestDeviceOptions& options,
58 blink::WebBluetoothRequestDeviceCallbacks* callbacks);
59
60 // WorkerThread::Observer implementation.
61 void WillStopCurrentWorkerThread() override;
62
63 private:
64 // IPC Handlers, see definitions in bluetooth_messages.h.
65 void OnRequestDeviceSuccess(int thread_id,
66 int request_id,
67 const BluetoothDevice& device);
68 void OnRequestDeviceError(int thread_id,
69 int request_id,
70 blink::WebBluetoothError error);
71
72 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
73
74 // Tracks device requests sent to browser to match replies with callbacks.
75 // Owns callback objects.
76 IDMap<blink::WebBluetoothRequestDeviceCallbacks, IDMapOwnPointer>
77 pending_requests_;
78
79 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher);
80 };
81
82 } // namespace content
83
84 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/bluetooth/bluetooth_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698