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

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

Issue 11428125: [Sync] Fix auth error handling while the backend is initializing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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) 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_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_
6 #define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ 6 #define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 30 matching lines...) Expand all
41 syncer::TestIdFactory& id_factory, 41 syncer::TestIdFactory& id_factory,
42 base::Closure& callback, 42 base::Closure& callback,
43 bool set_initial_sync_ended_on_init, 43 bool set_initial_sync_ended_on_init,
44 bool synchronous_init, 44 bool synchronous_init,
45 bool fail_initial_download, 45 bool fail_initial_download,
46 syncer::StorageOption storage_option); 46 syncer::StorageOption storage_option);
47 virtual ~SyncBackendHostForProfileSyncTest(); 47 virtual ~SyncBackendHostForProfileSyncTest();
48 48
49 MOCK_METHOD1(RequestNudge, void(const tracked_objects::Location&)); 49 MOCK_METHOD1(RequestNudge, void(const tracked_objects::Location&));
50 50
51 virtual void UpdateCredentials(
52 const syncer::SyncCredentials& credentials) OVERRIDE;
53
51 virtual void RequestConfigureSyncer( 54 virtual void RequestConfigureSyncer(
52 syncer::ConfigureReason reason, 55 syncer::ConfigureReason reason,
53 syncer::ModelTypeSet types_to_config, 56 syncer::ModelTypeSet types_to_config,
54 const syncer::ModelSafeRoutingInfo& routing_info, 57 const syncer::ModelSafeRoutingInfo& routing_info,
55 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, 58 const base::Callback<void(syncer::ModelTypeSet)>& ready_task,
56 const base::Closure& retry_callback) OVERRIDE; 59 const base::Closure& retry_callback) OVERRIDE;
57 60
58 virtual void HandleSyncManagerInitializationOnFrontendLoop( 61 virtual void HandleSyncManagerInitializationOnFrontendLoop(
59 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 62 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
60 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& 63 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
61 debug_info_listener, 64 debug_info_listener,
62 syncer::ModelTypeSet restored_types) OVERRIDE; 65 syncer::ModelTypeSet restored_types) OVERRIDE;
63 66
64 static void SetHistoryServiceExpectations(ProfileMock* profile); 67 static void SetHistoryServiceExpectations(ProfileMock* profile);
65 68
66 void SetInitialSyncEndedForAllTypes(); 69 void SetInitialSyncEndedForAllTypes();
67 70
68 void EmitOnInvalidatorStateChange(syncer::InvalidatorState state); 71 void EmitOnInvalidatorStateChange(syncer::InvalidatorState state);
69 void EmitOnIncomingInvalidation( 72 void EmitOnIncomingInvalidation(
70 const syncer::ObjectIdInvalidationMap& invalidation_map, 73 const syncer::ObjectIdInvalidationMap& invalidation_map,
71 const syncer::IncomingInvalidationSource source); 74 const syncer::IncomingInvalidationSource source);
72 75
73 protected: 76 protected:
74 virtual void InitCore(const DoInitializeOptions& options) OVERRIDE; 77 virtual void InitCore(const DoInitializeOptions& options) OVERRIDE;
75 78
76 private: 79 private:
80 void ContinueInitialization(
81 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
82 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
83 debug_info_listener,
84 syncer::ModelTypeSet restored_types);
85
86 base::WeakPtrFactory<SyncBackendHostForProfileSyncTest> weak_ptr_factory_;
87
77 syncer::TestIdFactory& id_factory_; 88 syncer::TestIdFactory& id_factory_;
89
90 // Invoked at the start of HandleSyncManagerInitializationOnFrontendLoop.
91 // Allows extra initialization work to be performed before the backend comes
92 // up.
78 base::Closure& callback_; 93 base::Closure& callback_;
79 94
95 // Saved closure in case we failed the initial download but then received
96 // new credentials. Holds the results of
97 // HandleSyncManagerInitializationOnFrontendLoop, and if
98 // |fail_initial_download_| was true, finishes the initialization process
99 // once we receive new credentials.
100 base::Closure initial_download_closure_;
101 bool fail_initial_download_;
102
80 bool set_initial_sync_ended_on_init_; 103 bool set_initial_sync_ended_on_init_;
81 bool synchronous_init_; 104 bool synchronous_init_;
82 bool fail_initial_download_;
83 syncer::StorageOption storage_option_; 105 syncer::StorageOption storage_option_;
84 }; 106 };
85 107
86 } // namespace browser_sync 108 } // namespace browser_sync
87 109
88 class TestProfileSyncService : public ProfileSyncService { 110 class TestProfileSyncService : public ProfileSyncService {
89 public: 111 public:
90 // |callback| can be used to populate nodes before the OnBackendInitialized 112 // |callback| can be used to populate nodes before the OnBackendInitialized
91 // callback fires. 113 // callback fires.
92 // TODO(tim): Remove |synchronous_backend_initialization|, and add ability to 114 // TODO(tim): Remove |synchronous_backend_initialization|, and add ability to
(...skipping 18 matching lines...) Expand all
111 const browser_sync::DataTypeManager::ConfigureResult& result) OVERRIDE; 133 const browser_sync::DataTypeManager::ConfigureResult& result) OVERRIDE;
112 134
113 // We implement our own version to avoid some DCHECKs. 135 // We implement our own version to avoid some DCHECKs.
114 virtual syncer::UserShare* GetUserShare() const OVERRIDE; 136 virtual syncer::UserShare* GetUserShare() const OVERRIDE;
115 137
116 // If this is called, configuring data types will require a syncer 138 // If this is called, configuring data types will require a syncer
117 // nudge. 139 // nudge.
118 void dont_set_initial_sync_ended_on_init(); 140 void dont_set_initial_sync_ended_on_init();
119 void set_synchronous_sync_configuration(); 141 void set_synchronous_sync_configuration();
120 142
143 // Fails initial download until a new auth token is provided.
121 void fail_initial_download(); 144 void fail_initial_download();
145
122 void set_storage_option(syncer::StorageOption option); 146 void set_storage_option(syncer::StorageOption option);
123 147
124 syncer::TestIdFactory* id_factory(); 148 syncer::TestIdFactory* id_factory();
125 149
126 // Override of ProfileSyncService::GetBackendForTest() with a more 150 // Override of ProfileSyncService::GetBackendForTest() with a more
127 // specific return type (since C++ supports covariant return types) 151 // specific return type (since C++ supports covariant return types)
128 // that is made public. 152 // that is made public.
129 virtual browser_sync::SyncBackendHostForProfileSyncTest* 153 virtual browser_sync::SyncBackendHostForProfileSyncTest*
130 GetBackendForTest() OVERRIDE; 154 GetBackendForTest() OVERRIDE;
131 155
(...skipping 10 matching lines...) Expand all
142 bool synchronous_sync_configuration_; 166 bool synchronous_sync_configuration_;
143 167
144 base::Closure callback_; 168 base::Closure callback_;
145 bool set_initial_sync_ended_on_init_; 169 bool set_initial_sync_ended_on_init_;
146 170
147 bool fail_initial_download_; 171 bool fail_initial_download_;
148 syncer::StorageOption storage_option_; 172 syncer::StorageOption storage_option_;
149 }; 173 };
150 174
151 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ 175 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_startup_unittest.cc ('k') | chrome/browser/sync/test_profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698