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

Side by Side Diff: chrome/browser/profiles/gaia_info_update_service.h

Issue 196243009: Just some cleanup before I start on the profile name fix. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/profiles/gaia_info_update_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_H_ 5 #ifndef CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_H_
6 #define CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_H_ 6 #define CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/prefs/pref_member.h"
12 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
13 #include "chrome/browser/profiles/profile_downloader.h" 12 #include "chrome/browser/profiles/profile_downloader.h"
14 #include "chrome/browser/profiles/profile_downloader_delegate.h" 13 #include "chrome/browser/profiles/profile_downloader_delegate.h"
15 #include "components/keyed_service/core/keyed_service.h" 14 #include "components/keyed_service/core/keyed_service.h"
15 #include "components/signin/core/browser/signin_manager.h"
16 16
17 class Profile; 17 class Profile;
18 class ProfileDownloader; 18 class ProfileDownloader;
19 19
20 // This service kicks off a download of the user's name and profile picture. 20 // This service kicks off a download of the user's name and profile picture.
21 // The results are saved in the profile info cache. 21 // The results are saved in the profile info cache.
22 class GAIAInfoUpdateService : public ProfileDownloaderDelegate, 22 class GAIAInfoUpdateService : public KeyedService,
23 public KeyedService { 23 public ProfileDownloaderDelegate,
24 public SigninManagerBase::Observer {
24 public: 25 public:
25 explicit GAIAInfoUpdateService(Profile* profile); 26 explicit GAIAInfoUpdateService(Profile* profile);
26 virtual ~GAIAInfoUpdateService(); 27 virtual ~GAIAInfoUpdateService();
27 28
28 // Updates the GAIA info for the profile associated with this instance. 29 // Updates the GAIA info for the profile associated with this instance.
29 virtual void Update(); 30 virtual void Update();
30 31
31 // Checks if downloading GAIA info for the given profile is allowed. 32 // Checks if downloading GAIA info for the given profile is allowed.
32 static bool ShouldUseGAIAProfileInfo(Profile* profile); 33 static bool ShouldUseGAIAProfileInfo(Profile* profile);
33 34
34 // ProfileDownloaderDelegate: 35 // ProfileDownloaderDelegate:
35 virtual bool NeedsProfilePicture() const OVERRIDE; 36 virtual bool NeedsProfilePicture() const OVERRIDE;
36 virtual int GetDesiredImageSideLength() const OVERRIDE; 37 virtual int GetDesiredImageSideLength() const OVERRIDE;
37 virtual Profile* GetBrowserProfile() OVERRIDE; 38 virtual Profile* GetBrowserProfile() OVERRIDE;
38 virtual std::string GetCachedPictureURL() const OVERRIDE; 39 virtual std::string GetCachedPictureURL() const OVERRIDE;
39 virtual void OnProfileDownloadSuccess(ProfileDownloader* downloader) OVERRIDE; 40 virtual void OnProfileDownloadSuccess(ProfileDownloader* downloader) OVERRIDE;
40 virtual void OnProfileDownloadFailure( 41 virtual void OnProfileDownloadFailure(
41 ProfileDownloader* downloader, 42 ProfileDownloader* downloader,
42 ProfileDownloaderDelegate::FailureReason reason) OVERRIDE; 43 ProfileDownloaderDelegate::FailureReason reason) OVERRIDE;
43 44
45 // Overridden from KeyedService:
46 virtual void Shutdown() OVERRIDE;
47
44 private: 48 private:
45 FRIEND_TEST_ALL_PREFIXES(GAIAInfoUpdateServiceTest, ScheduleUpdate); 49 FRIEND_TEST_ALL_PREFIXES(GAIAInfoUpdateServiceTest, ScheduleUpdate);
46 50
47 void OnUsernameChanged(); 51 void OnUsernameChanged(const std::string& username);
48 void ScheduleNextUpdate(); 52 void ScheduleNextUpdate();
49 53
54 // Overridden from SigninManagerBase::Observer:
55 virtual void GoogleSigninSucceeded(const std::string& username,
56 const std::string& password) OVERRIDE;
57 virtual void GoogleSignedOut(const std::string& username) OVERRIDE;
58
50 Profile* profile_; 59 Profile* profile_;
51 scoped_ptr<ProfileDownloader> profile_image_downloader_; 60 scoped_ptr<ProfileDownloader> profile_image_downloader_;
52 StringPrefMember username_pref_;
53 base::Time last_updated_; 61 base::Time last_updated_;
54 base::OneShotTimer<GAIAInfoUpdateService> timer_; 62 base::OneShotTimer<GAIAInfoUpdateService> timer_;
55 63
56 DISALLOW_COPY_AND_ASSIGN(GAIAInfoUpdateService); 64 DISALLOW_COPY_AND_ASSIGN(GAIAInfoUpdateService);
57 }; 65 };
58 66
59 #endif // CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_H_ 67 #endif // CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/gaia_info_update_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698