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

Unified 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: Created 6 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: content/child/bluetooth/bluetooth_dispatcher.h
diff --git a/content/child/bluetooth/bluetooth_dispatcher.h b/content/child/bluetooth/bluetooth_dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..1d4126fa3e78340cc0c4016faff30b054dad8c66
--- /dev/null
+++ b/content/child/bluetooth/bluetooth_dispatcher.h
@@ -0,0 +1,76 @@
+// Copyright 2014 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 CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_
+#define CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_
+
+#include "base/id_map.h"
+#include "base/memory/ref_counted.h"
+#include "content/child/worker_task_runner.h"
+#include "content/common/bluetooth/bluetooth_error.h"
+#include "third_party/WebKit/public/platform/WebBluetooth.h"
+
+namespace base {
+class MessageLoop;
+class TaskRunner;
+}
+
+namespace IPC {
+class Message;
+}
+
+namespace content {
+class ThreadSafeSender;
+
+class BluetoothDispatcher : public WorkerTaskRunner::Observer {
+ public:
+ explicit BluetoothDispatcher(ThreadSafeSender* sender);
+ ~BluetoothDispatcher() override;
+
+ // Gets or Creates a BluetoothDispatcher for the current thread.
+ // |thread_safe_sender| is required when constructing a BluetoothDispatcher.
+ static BluetoothDispatcher* GetOrCreateThreadSpecificInstance(
+ ThreadSafeSender* thread_safe_sender);
+
+ // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener.
+ bool Send(IPC::Message* msg);
+ void OnMessageReceived(const IPC::Message& msg);
+
+ // Corresponding to WebBluetoothImpl methods.
+ // TODO: Remove old void version after crrev.com/715613005 lands.
+ void requestDevice(
+ blink::WebCallbacks<void, blink::WebBluetoothError>* callbacks);
+ void requestDevice(blink::WebCallbacks<blink::WebBluetoothDevice,
+ blink::WebBluetoothError>* callbacks);
+ void SetBluetoothMockDataSetForTesting(const std::string& name);
+
+ // WorkerTaskRunner::Observer implementation.
+ void OnWorkerRunLoopStopped() override;
+
+ private:
+ // IPC Handlers, see definitions in bluetooth_messages.h.
+ void OnRequestDeviceSuccess(int thread_id,
+ int request_id,
+ const std::string& device_id);
Jeffrey Yasskin 2014/11/24 23:30:11 We should be consistent between instance_id and de
scheib 2014/11/25 16:11:06 Done.
+ void OnRequestDeviceError(int thread_id,
+ int request_id,
+ BluetoothError error_type);
+
+ scoped_refptr<ThreadSafeSender> thread_safe_sender_;
+
+ // Tracks requests sent to browser to match replies with callbacks.
+ // Owns callback objects.
+ // TODO: Remove old void version after crrev.com/715613005 lands.
+ IDMap<blink::WebCallbacks<void, blink::WebBluetoothError>, IDMapOwnPointer>
+ pending_requests_old_;
+ IDMap<
+ blink::WebCallbacks<blink::WebBluetoothDevice, blink::WebBluetoothError>,
+ IDMapOwnPointer> pending_requests_;
+
+ DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698