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

Side by Side Diff: chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc

Issue 566623003: Refactor syncable DEVICE_INFO type from ChangeProcessor to SyncableService - part 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More CR feedback addressed in DeviceInfoSyncService. Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/signed_in_devices/signed_in_devices_mana ger.h" 5 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_mana ger.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 26 matching lines...) Expand all
37 device_info.GetDeviceTypeString()); 37 device_info.GetDeviceTypeString());
38 api_device_info->chrome_version = device_info.chrome_version(); 38 api_device_info->chrome_version = device_info.chrome_version();
39 } 39 }
40 } // namespace 40 } // namespace
41 41
42 SignedInDevicesChangeObserver::SignedInDevicesChangeObserver( 42 SignedInDevicesChangeObserver::SignedInDevicesChangeObserver(
43 const std::string& extension_id, 43 const std::string& extension_id,
44 Profile* profile) : extension_id_(extension_id), 44 Profile* profile) : extension_id_(extension_id),
45 profile_(profile) { 45 profile_(profile) {
46 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile_); 46 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile_);
47 if (pss) { 47 if (pss && pss->GetDeviceInfoTracker()) {
48 pss->AddObserverForDeviceInfoChange(this); 48 pss->GetDeviceInfoTracker()->AddObserver(this);
49 } 49 }
50 } 50 }
51 51
52 SignedInDevicesChangeObserver::~SignedInDevicesChangeObserver() { 52 SignedInDevicesChangeObserver::~SignedInDevicesChangeObserver() {
53 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile_); 53 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile_);
54 if (pss) { 54 if (pss && pss->GetDeviceInfoTracker()) {
55 pss->RemoveObserverForDeviceInfoChange(this); 55 pss->GetDeviceInfoTracker()->RemoveObserver(this);
56 } 56 }
57
58 } 57 }
59 58
60 void SignedInDevicesChangeObserver::OnDeviceInfoChange() { 59 void SignedInDevicesChangeObserver::OnDeviceInfoChange() {
61 // There is a change in the list of devices. Get all devices and send them to 60 // There is a change in the list of devices. Get all devices and send them to
62 // the listener. 61 // the listener.
63 ScopedVector<DeviceInfo> devices = GetAllSignedInDevices(extension_id_, 62 ScopedVector<DeviceInfo> devices = GetAllSignedInDevices(extension_id_,
64 profile_); 63 profile_);
65 64
66 std::vector<linked_ptr<api::signed_in_devices::DeviceInfo> > args; 65 std::vector<linked_ptr<api::signed_in_devices::DeviceInfo> > args;
67 66
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 151 }
153 152
154 void SignedInDevicesManager::OnExtensionUnloaded( 153 void SignedInDevicesManager::OnExtensionUnloaded(
155 content::BrowserContext* browser_context, 154 content::BrowserContext* browser_context,
156 const Extension* extension, 155 const Extension* extension,
157 UnloadedExtensionInfo::Reason reason) { 156 UnloadedExtensionInfo::Reason reason) {
158 RemoveChangeObserverForExtension(extension->id()); 157 RemoveChangeObserverForExtension(extension->id());
159 } 158 }
160 159
161 } // namespace extensions 160 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698