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

Side by Side Diff: chrome/browser/chromeos/policy/cloud_external_data_policy_observer.h

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_POLICY_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_POLICY_OBSERVER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_POLICY_OBSERVER_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_POLICY_OBSERVER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory>
9 #include <string> 10 #include <string>
10 11
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" 16 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
17 #include "chrome/browser/chromeos/settings/cros_settings.h" 17 #include "chrome/browser/chromeos/settings/cros_settings.h"
18 #include "components/policy/core/common/policy_map.h" 18 #include "components/policy/core/common/policy_map.h"
19 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
21 21
22 namespace policy { 22 namespace policy {
23 23
24 // Helper for implementing policies referencing external data: This class 24 // Helper for implementing policies referencing external data: This class
(...skipping 19 matching lines...) Expand all
44 virtual void OnExternalDataCleared(const std::string& policy, 44 virtual void OnExternalDataCleared(const std::string& policy,
45 const std::string& user_id); 45 const std::string& user_id);
46 46
47 // Invoked when the external data referenced for |user_id| has been fetched. 47 // Invoked when the external data referenced for |user_id| has been fetched.
48 // Failed fetches are retried and the method is called only when a fetch 48 // Failed fetches are retried and the method is called only when a fetch
49 // eventually succeeds. If a fetch fails permanently (e.g. because the 49 // eventually succeeds. If a fetch fails permanently (e.g. because the
50 // external data reference specifies an invalid URL), the method is not 50 // external data reference specifies an invalid URL), the method is not
51 // called at all. 51 // called at all.
52 virtual void OnExternalDataFetched(const std::string& policy, 52 virtual void OnExternalDataFetched(const std::string& policy,
53 const std::string& user_id, 53 const std::string& user_id,
54 scoped_ptr<std::string> data); 54 std::unique_ptr<std::string> data);
55 55
56 protected: 56 protected:
57 virtual ~Delegate(); 57 virtual ~Delegate();
58 }; 58 };
59 59
60 CloudExternalDataPolicyObserver( 60 CloudExternalDataPolicyObserver(
61 chromeos::CrosSettings* cros_settings, 61 chromeos::CrosSettings* cros_settings,
62 DeviceLocalAccountPolicyService* device_local_account_policy_service, 62 DeviceLocalAccountPolicyService* device_local_account_policy_service,
63 const std::string& policy, 63 const std::string& policy,
64 Delegate* delegate); 64 Delegate* delegate);
(...skipping 17 matching lines...) Expand all
82 void RetrieveDeviceLocalAccounts(); 82 void RetrieveDeviceLocalAccounts();
83 83
84 // Handles the new policy map |entry| for |user_id| by canceling any external 84 // Handles the new policy map |entry| for |user_id| by canceling any external
85 // data fetch currently in progress, emitting a notification that an external 85 // data fetch currently in progress, emitting a notification that an external
86 // data reference has been cleared (if |entry| is NULL) or set (otherwise), 86 // data reference has been cleared (if |entry| is NULL) or set (otherwise),
87 // starting a new external data fetch in the latter case. 87 // starting a new external data fetch in the latter case.
88 void HandleExternalDataPolicyUpdate(const std::string& user_id, 88 void HandleExternalDataPolicyUpdate(const std::string& user_id,
89 const PolicyMap::Entry* entry); 89 const PolicyMap::Entry* entry);
90 90
91 void OnExternalDataFetched(const std::string& user_id, 91 void OnExternalDataFetched(const std::string& user_id,
92 scoped_ptr<std::string> data); 92 std::unique_ptr<std::string> data);
93 93
94 // A map from each device-local account user ID to its current policy map 94 // A map from each device-local account user ID to its current policy map
95 // entry for |policy_|. 95 // entry for |policy_|.
96 typedef std::map<std::string, PolicyMap::Entry> DeviceLocalAccountEntryMap; 96 typedef std::map<std::string, PolicyMap::Entry> DeviceLocalAccountEntryMap;
97 DeviceLocalAccountEntryMap device_local_account_entries_; 97 DeviceLocalAccountEntryMap device_local_account_entries_;
98 98
99 // A map from each logged-in user to the helper that observes |policy_| in the 99 // A map from each logged-in user to the helper that observes |policy_| in the
100 // user's PolicyService. 100 // user's PolicyService.
101 typedef std::map<std::string, linked_ptr<PolicyServiceObserver> > 101 typedef std::map<std::string, linked_ptr<PolicyServiceObserver> >
102 LoggedInUserObserverMap; 102 LoggedInUserObserverMap;
103 LoggedInUserObserverMap logged_in_user_observers_; 103 LoggedInUserObserverMap logged_in_user_observers_;
104 104
105 chromeos::CrosSettings* cros_settings_; 105 chromeos::CrosSettings* cros_settings_;
106 DeviceLocalAccountPolicyService* device_local_account_policy_service_; 106 DeviceLocalAccountPolicyService* device_local_account_policy_service_;
107 107
108 // The policy that |this| observes. 108 // The policy that |this| observes.
109 std::string policy_; 109 std::string policy_;
110 110
111 Delegate* delegate_; 111 Delegate* delegate_;
112 112
113 content::NotificationRegistrar notification_registrar_; 113 content::NotificationRegistrar notification_registrar_;
114 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> 114 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
115 device_local_accounts_subscription_; 115 device_local_accounts_subscription_;
116 116
117 // A map from user ID to a base::WeakPtr for each external data fetch 117 // A map from user ID to a base::WeakPtr for each external data fetch
118 // currently in progress. This allows fetches to be effectively be canceled by 118 // currently in progress. This allows fetches to be effectively be canceled by
119 // invalidating the pointers. 119 // invalidating the pointers.
120 typedef base::WeakPtrFactory<CloudExternalDataPolicyObserver> 120 typedef base::WeakPtrFactory<CloudExternalDataPolicyObserver>
121 WeakPtrFactory; 121 WeakPtrFactory;
122 typedef std::map<std::string, linked_ptr<WeakPtrFactory> > FetchWeakPtrMap; 122 typedef std::map<std::string, linked_ptr<WeakPtrFactory> > FetchWeakPtrMap;
123 FetchWeakPtrMap fetch_weak_ptrs_; 123 FetchWeakPtrMap fetch_weak_ptrs_;
124 124
125 base::WeakPtrFactory<CloudExternalDataPolicyObserver> weak_factory_; 125 base::WeakPtrFactory<CloudExternalDataPolicyObserver> weak_factory_;
126 126
127 DISALLOW_COPY_AND_ASSIGN(CloudExternalDataPolicyObserver); 127 DISALLOW_COPY_AND_ASSIGN(CloudExternalDataPolicyObserver);
128 }; 128 };
129 129
130 } // namespace policy 130 } // namespace policy
131 131
132 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_POLICY_OBSERVER_H_ 132 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_POLICY_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698