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

Side by Side Diff: extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.cc

Issue 820673004: json_schema_compiler: Use std::vector<char> for binary values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify_json_schema
Patch Set: Fix merge error. Created 5 years, 11 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 "extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatc her.h" 5 #include "extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatc her.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "device/bluetooth/bluetooth_device.h" 8 #include "device/bluetooth/bluetooth_device.h"
9 #include "device/bluetooth/bluetooth_socket.h" 9 #include "device/bluetooth/bluetooth_socket.h"
10 #include "extensions/browser/api/bluetooth_socket/bluetooth_api_socket.h" 10 #include "extensions/browser/api/bluetooth_socket/bluetooth_api_socket.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // static 184 // static
185 void BluetoothSocketEventDispatcher::ReceiveCallback( 185 void BluetoothSocketEventDispatcher::ReceiveCallback(
186 const SocketParams& params, 186 const SocketParams& params,
187 int bytes_read, 187 int bytes_read,
188 scoped_refptr<net::IOBuffer> io_buffer) { 188 scoped_refptr<net::IOBuffer> io_buffer) {
189 DCHECK(BrowserThread::CurrentlyOn(params.thread_id)); 189 DCHECK(BrowserThread::CurrentlyOn(params.thread_id));
190 190
191 // Dispatch "onReceive" event. 191 // Dispatch "onReceive" event.
192 bluetooth_socket::ReceiveInfo receive_info; 192 bluetooth_socket::ReceiveInfo receive_info;
193 receive_info.socket_id = params.socket_id; 193 receive_info.socket_id = params.socket_id;
194 receive_info.data = std::string(io_buffer->data(), bytes_read); 194 receive_info.data.assign(io_buffer->data(), io_buffer->data() + bytes_read);
195 scoped_ptr<base::ListValue> args = 195 scoped_ptr<base::ListValue> args =
196 bluetooth_socket::OnReceive::Create(receive_info); 196 bluetooth_socket::OnReceive::Create(receive_info);
197 scoped_ptr<Event> event( 197 scoped_ptr<Event> event(
198 new Event(bluetooth_socket::OnReceive::kEventName, args.Pass())); 198 new Event(bluetooth_socket::OnReceive::kEventName, args.Pass()));
199 PostEvent(params, event.Pass()); 199 PostEvent(params, event.Pass());
200 200
201 // Post a task to delay the read until the socket is available, as 201 // Post a task to delay the read until the socket is available, as
202 // calling StartReceive at this point would error with ERR_IO_PENDING. 202 // calling StartReceive at this point would error with ERR_IO_PENDING.
203 BrowserThread::PostTask( 203 BrowserThread::PostTask(
204 params.thread_id, 204 params.thread_id,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) 362 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context))
363 return; 363 return;
364 364
365 EventRouter* router = EventRouter::Get(context); 365 EventRouter* router = EventRouter::Get(context);
366 if (router) 366 if (router)
367 router->DispatchEventToExtension(extension_id, event.Pass()); 367 router->DispatchEventToExtension(extension_id, event.Pass());
368 } 368 }
369 369
370 } // namespace core_api 370 } // namespace core_api
371 } // namespace extensions 371 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698