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

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: fix compile failure on android. 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..6f492f64107025816194fb5fa5f531d7d6b2bdcd
--- /dev/null
+++ b/content/child/bluetooth/bluetooth_dispatcher.h
@@ -0,0 +1,84 @@
+// 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;
+
+// Dispatcher for child process threads which communicates to the browser's
+// BluetoothDispatcherHost.
+//
+// Instances are created for each thread as necessary by WebBluetoothImpl.
+//
+// Incoming IPC messages are received by the BluetoothMessageFilter and
+// directed to the thread specific instance of this class.
+// Outgoing messages come from WebBluetoothImpl.
+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(scheib): 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_instance_id);
+ 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(scheib): 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