| OLD | NEW |
| 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 15 matching lines...) Expand all Loading... |
| 26 #include "extensions/browser/api/bluetooth/bluetooth_private_api.h" | 26 #include "extensions/browser/api/bluetooth/bluetooth_private_api.h" |
| 27 #include "extensions/browser/event_router.h" | 27 #include "extensions/browser/event_router.h" |
| 28 #include "extensions/browser/extension_host.h" | 28 #include "extensions/browser/extension_host.h" |
| 29 #include "extensions/browser/extension_registry.h" | 29 #include "extensions/browser/extension_registry.h" |
| 30 #include "extensions/browser/notification_types.h" | 30 #include "extensions/browser/notification_types.h" |
| 31 #include "extensions/common/api/bluetooth.h" | 31 #include "extensions/common/api/bluetooth.h" |
| 32 #include "extensions/common/api/bluetooth_private.h" | 32 #include "extensions/common/api/bluetooth_private.h" |
| 33 | 33 |
| 34 namespace extensions { | 34 namespace extensions { |
| 35 | 35 |
| 36 namespace bluetooth = core_api::bluetooth; | 36 namespace bluetooth = api::bluetooth; |
| 37 namespace bt_private = core_api::bluetooth_private; | 37 namespace bt_private = api::bluetooth_private; |
| 38 | 38 |
| 39 BluetoothEventRouter::BluetoothEventRouter(content::BrowserContext* context) | 39 BluetoothEventRouter::BluetoothEventRouter(content::BrowserContext* context) |
| 40 : browser_context_(context), | 40 : browser_context_(context), |
| 41 adapter_(NULL), | 41 adapter_(NULL), |
| 42 num_event_listeners_(0), | 42 num_event_listeners_(0), |
| 43 extension_registry_observer_(this), | 43 extension_registry_observer_(this), |
| 44 weak_ptr_factory_(this) { | 44 weak_ptr_factory_(this) { |
| 45 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 45 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 46 DCHECK(browser_context_); | 46 DCHECK(browser_context_); |
| 47 registrar_.Add(this, | 47 registrar_.Add(this, |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 320 } |
| 321 | 321 |
| 322 void BluetoothEventRouter::OnListenerRemoved() { | 322 void BluetoothEventRouter::OnListenerRemoved() { |
| 323 if (num_event_listeners_ > 0) | 323 if (num_event_listeners_ > 0) |
| 324 num_event_listeners_--; | 324 num_event_listeners_--; |
| 325 MaybeReleaseAdapter(); | 325 MaybeReleaseAdapter(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 void BluetoothEventRouter::DispatchAdapterStateEvent() { | 328 void BluetoothEventRouter::DispatchAdapterStateEvent() { |
| 329 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 329 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 330 core_api::bluetooth::AdapterState state; | 330 api::bluetooth::AdapterState state; |
| 331 PopulateAdapterState(*adapter_.get(), &state); | 331 PopulateAdapterState(*adapter_.get(), &state); |
| 332 | 332 |
| 333 scoped_ptr<base::ListValue> args = | 333 scoped_ptr<base::ListValue> args = |
| 334 bluetooth::OnAdapterStateChanged::Create(state); | 334 bluetooth::OnAdapterStateChanged::Create(state); |
| 335 scoped_ptr<Event> event( | 335 scoped_ptr<Event> event( |
| 336 new Event(events::BLUETOOTH_ON_ADAPTER_STATE_CHANGED, | 336 new Event(events::BLUETOOTH_ON_ADAPTER_STATE_CHANGED, |
| 337 bluetooth::OnAdapterStateChanged::kEventName, args.Pass())); | 337 bluetooth::OnAdapterStateChanged::kEventName, args.Pass())); |
| 338 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 338 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
| 339 } | 339 } |
| 340 | 340 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 418 } |
| 419 | 419 |
| 420 void BluetoothEventRouter::OnExtensionUnloaded( | 420 void BluetoothEventRouter::OnExtensionUnloaded( |
| 421 content::BrowserContext* browser_context, | 421 content::BrowserContext* browser_context, |
| 422 const Extension* extension, | 422 const Extension* extension, |
| 423 UnloadedExtensionInfo::Reason reason) { | 423 UnloadedExtensionInfo::Reason reason) { |
| 424 CleanUpForExtension(extension->id()); | 424 CleanUpForExtension(extension->id()); |
| 425 } | 425 } |
| 426 | 426 |
| 427 } // namespace extensions | 427 } // namespace extensions |
| OLD | NEW |