| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/bluetooth/bluetooth_dispatcher.h" | 5 #include "content/child/bluetooth/bluetooth_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 | 99 |
| 100 void BluetoothDispatcher::OnWorkerRunLoopStopped() { | 100 void BluetoothDispatcher::OnWorkerRunLoopStopped() { |
| 101 delete this; | 101 delete this; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void BluetoothDispatcher::OnRequestDeviceSuccess( | 104 void BluetoothDispatcher::OnRequestDeviceSuccess( |
| 105 int thread_id, | 105 int thread_id, |
| 106 int request_id, | 106 int request_id, |
| 107 const std::string& device_instance_id) { | 107 const std::string& device_instance_id) { |
| 108 DCHECK(pending_requests_.Lookup(request_id)) << request_id; |
| 108 pending_requests_.Lookup(request_id) | 109 pending_requests_.Lookup(request_id) |
| 109 ->onSuccess( | 110 ->onSuccess( |
| 110 new WebBluetoothDevice(WebString::fromUTF8(device_instance_id))); | 111 new WebBluetoothDevice(WebString::fromUTF8(device_instance_id))); |
| 111 pending_requests_.Remove(request_id); | 112 pending_requests_.Remove(request_id); |
| 112 } | 113 } |
| 113 | 114 |
| 114 void BluetoothDispatcher::OnRequestDeviceError(int thread_id, | 115 void BluetoothDispatcher::OnRequestDeviceError(int thread_id, |
| 115 int request_id, | 116 int request_id, |
| 116 BluetoothError error_type) { | 117 BluetoothError error_type) { |
| 118 DCHECK(pending_requests_.Lookup(request_id)) << request_id; |
| 117 pending_requests_.Lookup(request_id) | 119 pending_requests_.Lookup(request_id) |
| 118 ->onError(new WebBluetoothError( | 120 ->onError(new WebBluetoothError( |
| 119 WebBluetoothErrorFromBluetoothError(error_type), "")); | 121 WebBluetoothErrorFromBluetoothError(error_type), "")); |
| 120 pending_requests_.Remove(request_id); | 122 pending_requests_.Remove(request_id); |
| 121 } | 123 } |
| 122 | 124 |
| 123 } // namespace content | 125 } // namespace content |
| OLD | NEW |