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

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

Issue 699843003: bluetooth: Impl uses new WebBluetoothDevice in content/browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Addressing comments from 12 - 14 Created 6 years 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
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 "base/id_map.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/child/worker_task_runner.h"
11 #include "content/common/bluetooth/bluetooth_error.h"
12 #include "third_party/WebKit/public/platform/WebBluetooth.h"
13
14 namespace base {
15 class MessageLoop;
16 class TaskRunner;
17 }
18
19 namespace IPC {
20 class Message;
21 }
22
23 namespace content {
24 class ThreadSafeSender;
25
26 class BluetoothDispatcher : public WorkerTaskRunner::Observer {
27 public:
28 explicit BluetoothDispatcher(ThreadSafeSender* sender);
29 ~BluetoothDispatcher() override;
30
31 // Gets or Creates a BluetoothDispatcher for the current thread.
32 // |thread_safe_sender| is required when constructing a BluetoothDispatcher.
33 static BluetoothDispatcher* GetOrCreateThreadSpecificInstance(
34 ThreadSafeSender* thread_safe_sender);
35
36 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener.
nasko 2014/11/25 23:27:01 You don't inherit from IPC::Sender and Listener in
scheib 2014/11/26 00:46:34 Yes. I've now explained this better above in class
37 bool Send(IPC::Message* msg);
38 void OnMessageReceived(const IPC::Message& msg);
39
40 // Corresponding to WebBluetoothImpl methods.
41 // TODO: Remove old void version after crrev.com/715613005 lands.
42 void requestDevice(
43 blink::WebCallbacks<void, blink::WebBluetoothError>* callbacks);
44 void requestDevice(blink::WebCallbacks<blink::WebBluetoothDevice,
45 blink::WebBluetoothError>* callbacks);
46 void SetBluetoothMockDataSetForTesting(const std::string& name);
47
48 // WorkerTaskRunner::Observer implementation.
49 void OnWorkerRunLoopStopped() override;
50
51 private:
52 // IPC Handlers, see definitions in bluetooth_messages.h.
53 void OnRequestDeviceSuccess(int thread_id,
54 int request_id,
55 const std::string& device_instance_id);
56 void OnRequestDeviceError(int thread_id,
57 int request_id,
58 BluetoothError error_type);
59
60 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
61
62 // Tracks requests sent to browser to match replies with callbacks.
63 // Owns callback objects.
64 // TODO: Remove old void version after crrev.com/715613005 lands.
65 IDMap<blink::WebCallbacks<void, blink::WebBluetoothError>, IDMapOwnPointer>
66 pending_requests_old_;
67 IDMap<
68 blink::WebCallbacks<blink::WebBluetoothDevice, blink::WebBluetoothError>,
69 IDMapOwnPointer> pending_requests_;
70
71 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher);
72 };
73
74 } // namespace content
75
76 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698