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

Side by Side Diff: chrome/browser/sync/profile_sync_service.h

Issue 9232011: sync: Make ProfileSyncService a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_SYNC_PROFILE_SYNC_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/observer_list.h" 18 #include "base/observer_list.h"
19 #include "base/string16.h" 19 #include "base/string16.h"
20 #include "base/time.h" 20 #include "base/time.h"
21 #include "base/timer.h" 21 #include "base/timer.h"
22 #include "chrome/browser/profiles/profile_keyed_service.h"
22 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" 23 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h"
23 #include "chrome/browser/sync/engine/model_safe_worker.h" 24 #include "chrome/browser/sync/engine/model_safe_worker.h"
24 #include "chrome/browser/sync/failed_datatypes_handler.h" 25 #include "chrome/browser/sync/failed_datatypes_handler.h"
25 #include "chrome/browser/sync/glue/data_type_controller.h" 26 #include "chrome/browser/sync/glue/data_type_controller.h"
26 #include "chrome/browser/sync/glue/sync_backend_host.h" 27 #include "chrome/browser/sync/glue/sync_backend_host.h"
27 #include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler. h" 28 #include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler. h"
28 #include "chrome/browser/sync/internal_api/sync_manager.h" 29 #include "chrome/browser/sync/internal_api/sync_manager.h"
29 #include "chrome/browser/sync/profile_sync_service_observer.h" 30 #include "chrome/browser/sync/profile_sync_service_observer.h"
30 #include "chrome/browser/sync/syncable/model_type.h" 31 #include "chrome/browser/sync/syncable/model_type.h"
31 #include "chrome/browser/sync/sync_js_controller.h" 32 #include "chrome/browser/sync/sync_js_controller.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // as necessary. 101 // as necessary.
101 // 102 //
102 // When a datatype is in the process of becoming active, it may be 103 // When a datatype is in the process of becoming active, it may be
103 // in some intermediate state. Those finer-grained intermediate states 104 // in some intermediate state. Those finer-grained intermediate states
104 // are differentiated by the DataTypeController state. 105 // are differentiated by the DataTypeController state.
105 // 106 //
106 class ProfileSyncService : public browser_sync::SyncFrontend, 107 class ProfileSyncService : public browser_sync::SyncFrontend,
107 public browser_sync::SyncPrefObserver, 108 public browser_sync::SyncPrefObserver,
108 public browser_sync::UnrecoverableErrorHandler, 109 public browser_sync::UnrecoverableErrorHandler,
109 public content::NotificationObserver, 110 public content::NotificationObserver,
111 public ProfileKeyedService,
110 // TODO(lipalani): crbug.com/100829. Instead of 112 // TODO(lipalani): crbug.com/100829. Instead of
111 // doing this vend weak pointers from a factory. 113 // doing this vend weak pointers from a factory.
112 public base::SupportsWeakPtr<ProfileSyncService> { 114 public base::SupportsWeakPtr<ProfileSyncService> {
113 public: 115 public:
114 typedef ProfileSyncServiceObserver Observer; 116 typedef ProfileSyncServiceObserver Observer;
115 typedef browser_sync::SyncBackendHost::Status Status; 117 typedef browser_sync::SyncBackendHost::Status Status;
116 118
117 enum SyncEventCodes { 119 enum SyncEventCodes {
118 MIN_SYNC_EVENT_CODE = 0, 120 MIN_SYNC_EVENT_CODE = 0,
119 121
(...skipping 30 matching lines...) Expand all
150 enum StartBehavior { 152 enum StartBehavior {
151 AUTO_START, 153 AUTO_START,
152 MANUAL_START, 154 MANUAL_START,
153 }; 155 };
154 156
155 // Default sync server URL. 157 // Default sync server URL.
156 static const char* kSyncServerUrl; 158 static const char* kSyncServerUrl;
157 // Sync server URL for dev channel users 159 // Sync server URL for dev channel users
158 static const char* kDevServerUrl; 160 static const char* kDevServerUrl;
159 161
162 // Takes ownership of |factory|.
160 ProfileSyncService(ProfileSyncComponentsFactory* factory, 163 ProfileSyncService(ProfileSyncComponentsFactory* factory,
161 Profile* profile, 164 Profile* profile,
162 SigninManager* signin, // Service takes ownership. 165 SigninManager* signin,
163 StartBehavior start_behavior); 166 StartBehavior start_behavior);
164 virtual ~ProfileSyncService(); 167 virtual ~ProfileSyncService();
165 168
166 // Initializes the object. This should be called every time an object of this 169 // Initializes the object. This should be called every time an object of this
167 // class is constructed. 170 // class is constructed.
168 void Initialize(); 171 void Initialize();
169 172
170 void RegisterAuthNotifications(); 173 void RegisterAuthNotifications();
171 174
172 // Same as AreCredentialsAvailable(false). 175 // Same as AreCredentialsAvailable(false).
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 return passphrase_required_reason_; 329 return passphrase_required_reason_;
327 } 330 }
328 331
329 // Returns a user-friendly string form of last synced time (in minutes). 332 // Returns a user-friendly string form of last synced time (in minutes).
330 virtual string16 GetLastSyncedTimeString() const; 333 virtual string16 GetLastSyncedTimeString() const;
331 334
332 const std::string& last_attempted_user_email() const { 335 const std::string& last_attempted_user_email() const {
333 return last_attempted_user_email_; 336 return last_attempted_user_email_;
334 } 337 }
335 338
339 ProfileSyncComponentsFactory* factory() { return factory_.get(); }
340
336 // The profile we are syncing for. 341 // The profile we are syncing for.
337 Profile* profile() const { return profile_; } 342 Profile* profile() const { return profile_; }
338 343
339 // Adds/removes an observer. ProfileSyncService does not take ownership of 344 // Adds/removes an observer. ProfileSyncService does not take ownership of
340 // the observer. 345 // the observer.
341 virtual void AddObserver(Observer* observer); 346 virtual void AddObserver(Observer* observer);
342 virtual void RemoveObserver(Observer* observer); 347 virtual void RemoveObserver(Observer* observer);
343 348
344 // Returns true if |observer| has already been added as an observer. 349 // Returns true if |observer| has already been added as an observer.
345 bool HasObserver(Observer* observer) const; 350 bool HasObserver(Observer* observer) const;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 void UnsuppressAndStart(); 491 void UnsuppressAndStart();
487 492
488 // Marks all currently registered types as "acknowledged" so we won't prompt 493 // Marks all currently registered types as "acknowledged" so we won't prompt
489 // the user about them any more. 494 // the user about them any more.
490 void AcknowledgeSyncedTypes(); 495 void AcknowledgeSyncedTypes();
491 496
492 SyncGlobalError* sync_global_error() { return sync_global_error_.get(); } 497 SyncGlobalError* sync_global_error() { return sync_global_error_.get(); }
493 498
494 virtual const FailedDatatypesHandler& failed_datatypes_handler(); 499 virtual const FailedDatatypesHandler& failed_datatypes_handler();
495 500
501 // ProfileKeyedService implementation.
502 virtual void Shutdown() OVERRIDE;
503
496 protected: 504 protected:
497 // Used by test classes that derive from ProfileSyncService. 505 // Used by test classes that derive from ProfileSyncService.
498 virtual browser_sync::SyncBackendHost* GetBackendForTest(); 506 virtual browser_sync::SyncBackendHost* GetBackendForTest();
499 507
500 // Helper to install and configure a data type manager. 508 // Helper to install and configure a data type manager.
501 void ConfigureDataTypeManager(); 509 void ConfigureDataTypeManager();
502 510
503 // Starts up the backend sync components. 511 // Starts up the backend sync components.
504 void StartUp(); 512 void StartUp();
505 // Shuts down the backend sync components. 513 // Shuts down the backend sync components.
506 // |sync_disabled| indicates if syncing is being disabled or not. 514 // |sync_disabled| indicates if syncing is being disabled or not.
507 void Shutdown(bool sync_disabled); 515 void ShutdownImpl(bool sync_disabled);
508 516
509 // Return SyncCredentials from the TokenService. 517 // Return SyncCredentials from the TokenService.
510 sync_api::SyncCredentials GetCredentials(); 518 sync_api::SyncCredentials GetCredentials();
511 519
512 // Test need to override this to create backends that allow setting up 520 // Test need to override this to create backends that allow setting up
513 // initial conditions, such as populating sync nodes. 521 // initial conditions, such as populating sync nodes.
514 // 522 //
515 // TODO(akalin): Figure out a better way to do this. Ideally, we'd 523 // TODO(akalin): Figure out a better way to do this. Ideally, we'd
516 // construct the backend outside this class and pass it in to the 524 // construct the backend outside this class and pass it in to the
517 // contructor or Initialize(). 525 // contructor or Initialize().
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 virtual void ReconfigureDatatypeManager(); 601 virtual void ReconfigureDatatypeManager();
594 602
595 603
596 // Time at which we begin an attempt a GAIA authorization. 604 // Time at which we begin an attempt a GAIA authorization.
597 base::TimeTicks auth_start_time_; 605 base::TimeTicks auth_start_time_;
598 606
599 // Time at which error UI is presented for the new tab page. 607 // Time at which error UI is presented for the new tab page.
600 base::TimeTicks auth_error_time_; 608 base::TimeTicks auth_error_time_;
601 609
602 // Factory used to create various dependent objects. 610 // Factory used to create various dependent objects.
603 ProfileSyncComponentsFactory* factory_; 611 scoped_ptr<ProfileSyncComponentsFactory> factory_;
604 612
605 // The profile whose data we are synchronizing. 613 // The profile whose data we are synchronizing.
606 Profile* profile_; 614 Profile* profile_;
607 615
608 // The class that handles getting, setting, and persisting sync 616 // The class that handles getting, setting, and persisting sync
609 // preferences. 617 // preferences.
610 browser_sync::SyncPrefs sync_prefs_; 618 browser_sync::SyncPrefs sync_prefs_;
611 619
612 // TODO(ncarter): Put this in a profile, once there is UI for it. 620 // TODO(ncarter): Put this in a profile, once there is UI for it.
613 // This specifies where to find the sync server. 621 // This specifies where to find the sync server.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 backend_unrecoverable_error_handler_; 721 backend_unrecoverable_error_handler_;
714 722
715 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); 723 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
716 }; 724 };
717 725
718 bool ShouldShowActionOnUI( 726 bool ShouldShowActionOnUI(
719 const browser_sync::SyncProtocolError& error); 727 const browser_sync::SyncProtocolError& error);
720 728
721 729
722 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ 730 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_components_factory_mock.h ('k') | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698