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

Side by Side Diff: chrome/browser/policy/device_token_fetcher.h

Issue 5624002: Move more code from headers to implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_POLICY_DEVICE_TOKEN_FETCHER_H_ 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_
6 #define CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_ 6 #define CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 25 matching lines...) Expand all
36 class Observer { 36 class Observer {
37 public: 37 public:
38 virtual void OnTokenSuccess() = 0; 38 virtual void OnTokenSuccess() = 0;
39 virtual void OnTokenError() = 0; 39 virtual void OnTokenError() = 0;
40 virtual void OnNotManaged() = 0; 40 virtual void OnNotManaged() = 0;
41 virtual ~Observer() {} 41 virtual ~Observer() {}
42 }; 42 };
43 43
44 class ObserverRegistrar { 44 class ObserverRegistrar {
45 public: 45 public:
46 void Init(DeviceTokenFetcher* token_fetcher) { 46 ObserverRegistrar();
47 token_fetcher_ = token_fetcher; 47 ~ObserverRegistrar();
48 } 48
49 ~ObserverRegistrar() { 49 void Init(DeviceTokenFetcher* token_fetcher);
50 RemoveAll(); 50 void AddObserver(DeviceTokenFetcher::Observer* observer);
51 } 51 void RemoveAll();
52 void AddObserver(DeviceTokenFetcher::Observer* observer) {
53 observers_.push_back(observer);
54 token_fetcher_->AddObserver(observer);
55 }
56 void RemoveAll() {
57 for (std::vector<DeviceTokenFetcher::Observer*>::iterator it =
58 observers_.begin(); it != observers_.end(); ++it) {
59 token_fetcher_->RemoveObserver(*it);
60 }
61 observers_.clear();
62 }
63 private: 52 private:
64 DeviceTokenFetcher* token_fetcher_; 53 DeviceTokenFetcher* token_fetcher_;
65 std::vector<DeviceTokenFetcher::Observer*> observers_; 54 std::vector<DeviceTokenFetcher::Observer*> observers_;
66 }; 55 };
67 56
68 // Requests to the device management server are sent through |backend|. It 57 // Requests to the device management server are sent through |backend|. It
69 // obtains the authentication token from |token_service|. The fetcher stores 58 // obtains the authentication token from |token_service|. The fetcher stores
70 // the device token to |token_path| once it's retrieved from the server. 59 // the device token to |token_path| once it's retrieved from the server.
71 DeviceTokenFetcher(DeviceManagementBackend* backend, 60 DeviceTokenFetcher(DeviceManagementBackend* backend,
72 Profile* profile, 61 Profile* profile,
73 const FilePath& token_path); 62 const FilePath& token_path);
74 virtual ~DeviceTokenFetcher() {} 63 virtual ~DeviceTokenFetcher();
75 64
76 // NotificationObserver method overrides: 65 // NotificationObserver method overrides:
77 virtual void Observe(NotificationType type, 66 virtual void Observe(NotificationType type,
78 const NotificationSource& source, 67 const NotificationSource& source,
79 const NotificationDetails& details); 68 const NotificationDetails& details);
80 69
81 // DeviceManagementBackend::DeviceRegisterResponseDelegate method overrides: 70 // DeviceManagementBackend::DeviceRegisterResponseDelegate method overrides:
82 virtual void HandleRegisterResponse( 71 virtual void HandleRegisterResponse(
83 const em::DeviceRegisterResponse& response); 72 const em::DeviceRegisterResponse& response);
84 virtual void OnError(DeviceManagementBackend::ErrorCode code); 73 virtual void OnError(DeviceManagementBackend::ErrorCode code);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // or it has been determined that there was an error during fetching. 195 // or it has been determined that there was an error during fetching.
207 base::WaitableEvent device_token_load_complete_event_; 196 base::WaitableEvent device_token_load_complete_event_;
208 197
209 // Registers the fetcher for notification of successful Gaia logins. 198 // Registers the fetcher for notification of successful Gaia logins.
210 NotificationRegistrar registrar_; 199 NotificationRegistrar registrar_;
211 }; 200 };
212 201
213 } // namespace policy 202 } // namespace policy
214 203
215 #endif // CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_ 204 #endif // CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698