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

Side by Side Diff: extensions/browser/api/bluetooth/bluetooth_event_router.cc

Issue 1201063002: Set up the infrastructure for Extension event metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaaaaase Created 5 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bluetooth_event_router.h" 5 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 MaybeReleaseAdapter(); 322 MaybeReleaseAdapter();
323 } 323 }
324 324
325 void BluetoothEventRouter::DispatchAdapterStateEvent() { 325 void BluetoothEventRouter::DispatchAdapterStateEvent() {
326 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 326 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
327 core_api::bluetooth::AdapterState state; 327 core_api::bluetooth::AdapterState state;
328 PopulateAdapterState(*adapter_.get(), &state); 328 PopulateAdapterState(*adapter_.get(), &state);
329 329
330 scoped_ptr<base::ListValue> args = 330 scoped_ptr<base::ListValue> args =
331 bluetooth::OnAdapterStateChanged::Create(state); 331 bluetooth::OnAdapterStateChanged::Create(state);
332 scoped_ptr<Event> event(new Event( 332 scoped_ptr<Event> event(
333 bluetooth::OnAdapterStateChanged::kEventName, 333 new Event(events::UNKNOWN, bluetooth::OnAdapterStateChanged::kEventName,
334 args.Pass())); 334 args.Pass()));
335 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); 335 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass());
336 } 336 }
337 337
338 void BluetoothEventRouter::DispatchDeviceEvent( 338 void BluetoothEventRouter::DispatchDeviceEvent(
339 const std::string& event_name, 339 const std::string& event_name,
340 device::BluetoothDevice* device) { 340 device::BluetoothDevice* device) {
341 bluetooth::Device extension_device; 341 bluetooth::Device extension_device;
342 bluetooth::BluetoothDeviceToApiDevice(*device, &extension_device); 342 bluetooth::BluetoothDeviceToApiDevice(*device, &extension_device);
343 343
344 scoped_ptr<base::ListValue> args = 344 scoped_ptr<base::ListValue> args =
345 bluetooth::OnDeviceAdded::Create(extension_device); 345 bluetooth::OnDeviceAdded::Create(extension_device);
346 scoped_ptr<Event> event(new Event(event_name, args.Pass())); 346 scoped_ptr<Event> event(new Event(events::UNKNOWN, event_name, args.Pass()));
347 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); 347 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass());
348 } 348 }
349 349
350 void BluetoothEventRouter::CleanUpForExtension( 350 void BluetoothEventRouter::CleanUpForExtension(
351 const std::string& extension_id) { 351 const std::string& extension_id) {
352 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 352 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
353 RemovePairingDelegate(extension_id); 353 RemovePairingDelegate(extension_id);
354 354
355 PreSetFilterMap::iterator pre_set_iter = 355 PreSetFilterMap::iterator pre_set_iter =
356 pre_set_filter_map_.find(extension_id); 356 pre_set_filter_map_.find(extension_id);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 414 }
415 415
416 void BluetoothEventRouter::OnExtensionUnloaded( 416 void BluetoothEventRouter::OnExtensionUnloaded(
417 content::BrowserContext* browser_context, 417 content::BrowserContext* browser_context,
418 const Extension* extension, 418 const Extension* extension,
419 UnloadedExtensionInfo::Reason reason) { 419 UnloadedExtensionInfo::Reason reason) {
420 CleanUpForExtension(extension->id()); 420 CleanUpForExtension(extension->id());
421 } 421 }
422 422
423 } // namespace extensions 423 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698