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

Side by Side Diff: content/renderer/bluetooth/bluetooth_dispatcher.cc

Issue 1873783003: Convert //content/renderer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
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/renderer/bluetooth/bluetooth_dispatcher.h" 5 #include "content/renderer/bluetooth/bluetooth_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
16 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
17 #include "content/child/thread_safe_sender.h" 16 #include "content/child/thread_safe_sender.h"
18 #include "content/common/bluetooth/bluetooth_messages.h" 17 #include "content/common/bluetooth/bluetooth_messages.h"
19 #include "device/bluetooth/bluetooth_uuid.h" 18 #include "device/bluetooth/bluetooth_uuid.h"
20 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDevic e.h" 19 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDevic e.h"
21 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothError .h" 20 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothError .h"
22 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemot eGATTCharacteristic.h" 21 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemot eGATTCharacteristic.h"
23 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemot eGATTCharacteristicInit.h" 22 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemot eGATTCharacteristicInit.h"
24 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemot eGATTService.h" 23 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemot eGATTService.h"
(...skipping 18 matching lines...) Expand all
43 blink::WebString device_id, 42 blink::WebString device_id,
44 blink::WebString service_uuid, 43 blink::WebString service_uuid,
45 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks) 44 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks)
46 : device_id(device_id), 45 : device_id(device_id),
47 service_uuid(service_uuid), 46 service_uuid(service_uuid),
48 callbacks(callbacks) {} 47 callbacks(callbacks) {}
49 ~BluetoothPrimaryServiceRequest() {} 48 ~BluetoothPrimaryServiceRequest() {}
50 49
51 blink::WebString device_id; 50 blink::WebString device_id;
52 blink::WebString service_uuid; 51 blink::WebString service_uuid;
53 scoped_ptr<blink::WebBluetoothGetPrimaryServiceCallbacks> callbacks; 52 std::unique_ptr<blink::WebBluetoothGetPrimaryServiceCallbacks> callbacks;
54 }; 53 };
55 54
56 struct BluetoothCharacteristicRequest { 55 struct BluetoothCharacteristicRequest {
57 BluetoothCharacteristicRequest( 56 BluetoothCharacteristicRequest(
58 blink::WebString service_instance_id, 57 blink::WebString service_instance_id,
59 blink::WebString characteristic_uuid, 58 blink::WebString characteristic_uuid,
60 blink::WebBluetoothGetCharacteristicCallbacks* callbacks) 59 blink::WebBluetoothGetCharacteristicCallbacks* callbacks)
61 : service_instance_id(service_instance_id), 60 : service_instance_id(service_instance_id),
62 characteristic_uuid(characteristic_uuid), 61 characteristic_uuid(characteristic_uuid),
63 callbacks(callbacks) {} 62 callbacks(callbacks) {}
64 ~BluetoothCharacteristicRequest() {} 63 ~BluetoothCharacteristicRequest() {}
65 64
66 blink::WebString service_instance_id; 65 blink::WebString service_instance_id;
67 blink::WebString characteristic_uuid; 66 blink::WebString characteristic_uuid;
68 scoped_ptr<blink::WebBluetoothGetCharacteristicCallbacks> callbacks; 67 std::unique_ptr<blink::WebBluetoothGetCharacteristicCallbacks> callbacks;
69 }; 68 };
70 69
71 struct BluetoothCharacteristicsRequest { 70 struct BluetoothCharacteristicsRequest {
72 BluetoothCharacteristicsRequest( 71 BluetoothCharacteristicsRequest(
73 blink::WebString service_instance_id, 72 blink::WebString service_instance_id,
74 blink::WebBluetoothGetCharacteristicsCallbacks* callbacks) 73 blink::WebBluetoothGetCharacteristicsCallbacks* callbacks)
75 : service_instance_id(service_instance_id), callbacks(callbacks) {} 74 : service_instance_id(service_instance_id), callbacks(callbacks) {}
76 ~BluetoothCharacteristicsRequest() {} 75 ~BluetoothCharacteristicsRequest() {}
77 76
78 blink::WebString service_instance_id; 77 blink::WebString service_instance_id;
79 scoped_ptr<blink::WebBluetoothGetCharacteristicsCallbacks> callbacks; 78 std::unique_ptr<blink::WebBluetoothGetCharacteristicsCallbacks> callbacks;
80 }; 79 };
81 80
82 // Struct that holds a pending Start/StopNotifications request. 81 // Struct that holds a pending Start/StopNotifications request.
83 struct BluetoothNotificationsRequest { 82 struct BluetoothNotificationsRequest {
84 BluetoothNotificationsRequest( 83 BluetoothNotificationsRequest(
85 int frame_routing_id, 84 int frame_routing_id,
86 const std::string characteristic_instance_id, 85 const std::string characteristic_instance_id,
87 blink::WebBluetoothRemoteGATTCharacteristic* characteristic, 86 blink::WebBluetoothRemoteGATTCharacteristic* characteristic,
88 blink::WebBluetoothNotificationsCallbacks* callbacks, 87 blink::WebBluetoothNotificationsCallbacks* callbacks,
89 NotificationsRequestType type) 88 NotificationsRequestType type)
90 : frame_routing_id(frame_routing_id), 89 : frame_routing_id(frame_routing_id),
91 characteristic_instance_id(characteristic_instance_id), 90 characteristic_instance_id(characteristic_instance_id),
92 characteristic(characteristic), 91 characteristic(characteristic),
93 callbacks(callbacks), 92 callbacks(callbacks),
94 type(type) {} 93 type(type) {}
95 ~BluetoothNotificationsRequest() {} 94 ~BluetoothNotificationsRequest() {}
96 95
97 const int frame_routing_id; 96 const int frame_routing_id;
98 const std::string characteristic_instance_id; 97 const std::string characteristic_instance_id;
99 // The characteristic object is owned by the execution context on 98 // The characteristic object is owned by the execution context on
100 // the blink side which can destroy the object at any point. Since the 99 // the blink side which can destroy the object at any point. Since the
101 // object implements ActiveDOMObject, the object calls Stop when is getting 100 // object implements ActiveDOMObject, the object calls Stop when is getting
102 // destroyed, which in turn calls characteristicObjectRemoved. 101 // destroyed, which in turn calls characteristicObjectRemoved.
103 // characteristicObjectRemoved will null any pointers to the object 102 // characteristicObjectRemoved will null any pointers to the object
104 // and queue a stop notifications request if necessary. 103 // and queue a stop notifications request if necessary.
105 blink::WebBluetoothRemoteGATTCharacteristic* characteristic; 104 blink::WebBluetoothRemoteGATTCharacteristic* characteristic;
106 scoped_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks; 105 std::unique_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks;
107 NotificationsRequestType type; 106 NotificationsRequestType type;
108 }; 107 };
109 108
110 namespace content { 109 namespace content {
111 110
112 namespace { 111 namespace {
113 112
114 base::LazyInstance<base::ThreadLocalPointer<void>>::Leaky g_dispatcher_tls = 113 base::LazyInstance<base::ThreadLocalPointer<void>>::Leaky g_dispatcher_tls =
115 LAZY_INSTANCE_INITIALIZER; 114 LAZY_INSTANCE_INITIALIZER;
116 115
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 int thread_id, 823 int thread_id,
825 const std::string& characteristic_instance_id, 824 const std::string& characteristic_instance_id,
826 const std::vector<uint8_t> new_value) { 825 const std::vector<uint8_t> new_value) {
827 auto active_iter = active_characteristics_.find(characteristic_instance_id); 826 auto active_iter = active_characteristics_.find(characteristic_instance_id);
828 if (active_iter != active_characteristics_.end()) { 827 if (active_iter != active_characteristics_.end()) {
829 active_iter->second->dispatchCharacteristicValueChanged(new_value); 828 active_iter->second->dispatchCharacteristicValueChanged(new_value);
830 } 829 }
831 } 830 }
832 831
833 } // namespace content 832 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/synchronous_compositor_proxy.cc ('k') | content/renderer/bluetooth/web_bluetooth_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698