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

Side by Side Diff: chrome/browser/extensions/api/cast_devices_private/cast_devices_private_api.cc

Issue 1567103005: Replace base::CallbackList with base::ObserverList in CastConfigDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Replace with ObserverList instead of base::Callback Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/extensions/api/cast_devices_private/cast_devices_privat e_api.h" 5 #include "chrome/browser/extensions/api/cast_devices_private/cast_devices_privat e_api.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/common/extensions/api/cast_devices_private.h" 9 #include "chrome/common/extensions/api/cast_devices_private.h"
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 CastDeviceUpdateListeners* CastDeviceUpdateListeners::Get( 58 CastDeviceUpdateListeners* CastDeviceUpdateListeners::Get(
59 content::BrowserContext* context) { 59 content::BrowserContext* context) {
60 return BrowserContextKeyedAPIFactory<CastDeviceUpdateListeners>::Get(context); 60 return BrowserContextKeyedAPIFactory<CastDeviceUpdateListeners>::Get(context);
61 } 61 }
62 62
63 CastDeviceUpdateListeners::CastDeviceUpdateListeners( 63 CastDeviceUpdateListeners::CastDeviceUpdateListeners(
64 content::BrowserContext* context) {} 64 content::BrowserContext* context) {}
65 65
66 CastDeviceUpdateListeners::~CastDeviceUpdateListeners() {} 66 CastDeviceUpdateListeners::~CastDeviceUpdateListeners() {}
67 67
68 ash::CastConfigDelegate::DeviceUpdateSubscription 68 void CastDeviceUpdateListeners::AddObserver(
69 CastDeviceUpdateListeners::RegisterCallback( 69 ash::CastConfigDelegate::Observer* observer) {
70 const ash::CastConfigDelegate::ReceiversAndActivitesCallback& callback) { 70 observer_list_.AddObserver(observer);
71 return callback_list_.Add(callback); 71 }
72
73 void CastDeviceUpdateListeners::RemoveObserver(
74 ash::CastConfigDelegate::Observer* observer) {
75 observer_list_.RemoveObserver(observer);
72 } 76 }
73 77
74 void CastDeviceUpdateListeners::NotifyCallbacks( 78 void CastDeviceUpdateListeners::NotifyCallbacks(
75 const ReceiverAndActivityList& devices) { 79 const ReceiverAndActivityList& devices) {
76 callback_list_.Notify(devices); 80 FOR_EACH_OBSERVER(ash::CastConfigDelegate::Observer, observer_list_,
81 OnDevicesUpdated(devices));
77 } 82 }
78 83
79 CastDevicesPrivateUpdateDevicesFunction:: 84 CastDevicesPrivateUpdateDevicesFunction::
80 CastDevicesPrivateUpdateDevicesFunction() {} 85 CastDevicesPrivateUpdateDevicesFunction() {}
81 86
82 CastDevicesPrivateUpdateDevicesFunction:: 87 CastDevicesPrivateUpdateDevicesFunction::
83 ~CastDevicesPrivateUpdateDevicesFunction() {} 88 ~CastDevicesPrivateUpdateDevicesFunction() {}
84 89
85 ExtensionFunction::ResponseAction 90 ExtensionFunction::ResponseAction
86 CastDevicesPrivateUpdateDevicesFunction::Run() { 91 CastDevicesPrivateUpdateDevicesFunction::Run() {
87 auto params = 92 auto params =
88 api::cast_devices_private::UpdateDevices::Params::Create(*args_); 93 api::cast_devices_private::UpdateDevices::Params::Create(*args_);
89 94
90 CastDeviceUpdateListeners::ReceiverAndActivityList devices; 95 CastDeviceUpdateListeners::ReceiverAndActivityList devices;
91 for (linked_ptr<api::cast_devices_private::ReceiverActivity> device : 96 for (linked_ptr<api::cast_devices_private::ReceiverActivity> device :
92 params->devices) { 97 params->devices) {
93 devices.push_back(ConvertReceiverAndActivityType(device->receiver, 98 devices.push_back(ConvertReceiverAndActivityType(device->receiver,
94 device->activity.get())); 99 device->activity.get()));
95 } 100 }
96 101
97 auto listeners = CastDeviceUpdateListeners::Get(browser_context()); 102 auto listeners = CastDeviceUpdateListeners::Get(browser_context());
98 listeners->NotifyCallbacks(devices); 103 listeners->NotifyCallbacks(devices);
99 104
100 return RespondNow(NoArguments()); 105 return RespondNow(NoArguments());
101 } 106 }
102 107
103 } // namespace extensions 108 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698