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

Side by Side Diff: content/browser/bluetooth/bluetooth_dispatcher_host.cc

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 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 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h"
6
7 #include "content/common/bluetooth/bluetooth_messages.h"
8
9 namespace content {
10
11 BluetoothDispatcherHost::BluetoothDispatcherHost()
12 : BrowserMessageFilter(BluetoothMsgStart),
13 bluetoothMockDataSet_(MockData::NOT_MOCKING),
14 bluetoothRequestDeviceRejectType_(BluetoothError::NOT_FOUND) {
15 }
16
17 bool BluetoothDispatcherHost::OnMessageReceived(const IPC::Message& message) {
18 bool handled = true;
19 IPC_BEGIN_MESSAGE_MAP(BluetoothDispatcherHost, message)
20 IPC_MESSAGE_HANDLER(BluetoothHostMsg_RequestDevice, OnRequestDevice)
21 IPC_MESSAGE_HANDLER(BluetoothHostMsg_SetBluetoothMockDataSetForTesting,
22 OnSetBluetoothMockDataSetForTesting)
23 IPC_MESSAGE_UNHANDLED(handled = false)
24 IPC_END_MESSAGE_MAP()
25 return handled;
26 }
27
28 BluetoothDispatcherHost::~BluetoothDispatcherHost() {
29 }
30
31 void BluetoothDispatcherHost::OnRequestDevice(int thread_id, int request_id) {
32 // Mock implementation util a more complete implementation is built out.
33 switch (bluetoothMockDataSet_) {
34 case MockData::NOT_MOCKING: {
35 Send(new BluetoothMsg_RequestDeviceError(thread_id, request_id,
36 BluetoothError::NOT_FOUND));
37 return;
nasko 2014/11/25 00:57:23 No need to return here, just plain break would wor
Jeffrey Yasskin 2014/11/25 01:08:07 Using return here, and the NOTREACHED after the sw
scheib 2014/11/25 16:11:06 Yes, as Jeffrey said, I prefer compile failure whe
nasko 2014/11/25 23:27:01 Heh, I learn something new every day. Thanks for t
38 }
39 case MockData::REJECT: {
40 Send(new BluetoothMsg_RequestDeviceError(
41 thread_id, request_id, bluetoothRequestDeviceRejectType_));
42 return;
43 }
44 case MockData::RESOLVE: {
45 Send(new BluetoothMsg_RequestDeviceSuccess(thread_id, request_id,
46 "Empty Mock deviceId"));
47 return;
48 }
49 }
50 NOTREACHED();
nasko 2014/11/25 00:57:23 This belongs in a default switch statement.
scheib 2014/11/25 16:11:05 Intended, see above re compile checking all enum c
51 }
52
53 void BluetoothDispatcherHost::OnSetBluetoothMockDataSetForTesting(
54 const std::string& name) {
55 if (name == "RejectRequestDevice_NotFoundError") {
56 bluetoothMockDataSet_ = MockData::REJECT;
57 bluetoothRequestDeviceRejectType_ = BluetoothError::NOT_FOUND;
58 } else if (name == "RejectRequestDevice_SecurityError") {
59 bluetoothMockDataSet_ = MockData::REJECT;
60 bluetoothRequestDeviceRejectType_ = BluetoothError::SECURITY;
61 } else if (name == "ResolveRequestDevice_Empty" || // TODO Remove.
Jeffrey Yasskin 2014/11/24 23:30:11 TODOs generally have a '(username):' after them: h
scheib 2014/11/25 16:11:05 Done.
62 name == "Single Empty Device") {
63 bluetoothMockDataSet_ = MockData::RESOLVE;
64 } else {
65 bluetoothMockDataSet_ = MockData::NOT_MOCKING;
66 }
67 }
68
69 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698