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

Side by Side Diff: sync/engine/sync_scheduler_unittest.cc

Issue 23189021: sync: Gracefully handle very early shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Retry: sync non-blocking early shutdown Created 7 years, 3 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 | « sync/engine/sync_scheduler_impl.cc ('k') | sync/engine/syncer.h » ('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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 23 matching lines...) Expand all
34 using testing::WithArg; 34 using testing::WithArg;
35 using testing::WithArgs; 35 using testing::WithArgs;
36 36
37 namespace syncer { 37 namespace syncer {
38 using sessions::SyncSession; 38 using sessions::SyncSession;
39 using sessions::SyncSessionContext; 39 using sessions::SyncSessionContext;
40 using sync_pb::GetUpdatesCallerInfo; 40 using sync_pb::GetUpdatesCallerInfo;
41 41
42 class MockSyncer : public Syncer { 42 class MockSyncer : public Syncer {
43 public: 43 public:
44 MockSyncer();
44 MOCK_METHOD3(NormalSyncShare, bool(ModelTypeSet, 45 MOCK_METHOD3(NormalSyncShare, bool(ModelTypeSet,
45 const sessions::NudgeTracker&, 46 const sessions::NudgeTracker&,
46 sessions::SyncSession*)); 47 sessions::SyncSession*));
47 MOCK_METHOD3(ConfigureSyncShare, 48 MOCK_METHOD3(ConfigureSyncShare,
48 bool(ModelTypeSet, 49 bool(ModelTypeSet,
49 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource, 50 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource,
50 SyncSession*)); 51 SyncSession*));
51 MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, sessions::SyncSession*)); 52 MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, sessions::SyncSession*));
52 }; 53 };
53 54
55 MockSyncer::MockSyncer()
56 : Syncer(NULL) {}
57
54 typedef std::vector<TimeTicks> SyncShareTimes; 58 typedef std::vector<TimeTicks> SyncShareTimes;
55 59
56 void QuitLoopNow() { 60 void QuitLoopNow() {
57 // We use QuitNow() instead of Quit() as the latter may get stalled 61 // We use QuitNow() instead of Quit() as the latter may get stalled
58 // indefinitely in the presence of repeated timers with low delays 62 // indefinitely in the presence of repeated timers with low delays
59 // and a slow test (e.g., ThrottlingDoesThrottle [which has a poll 63 // and a slow test (e.g., ThrottlingDoesThrottle [which has a poll
60 // delay of 5ms] run under TSAN on the trybots). 64 // delay of 5ms] run under TSAN on the trybots).
61 base::MessageLoop::current()->QuitNow(); 65 base::MessageLoop::current()->QuitNow();
62 } 66 }
63 67
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 // poll once more 1200 // poll once more
1197 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) 1201 EXPECT_CALL(*syncer(), PollSyncShare(_,_))
1198 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), 1202 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess),
1199 RecordSyncShare(&times))); 1203 RecordSyncShare(&times)));
1200 scheduler()->OnCredentialsUpdated(); 1204 scheduler()->OnCredentialsUpdated();
1201 connection()->SetServerStatus(HttpResponse::SERVER_CONNECTION_OK); 1205 connection()->SetServerStatus(HttpResponse::SERVER_CONNECTION_OK);
1202 StopSyncScheduler(); 1206 StopSyncScheduler();
1203 } 1207 }
1204 1208
1205 } // namespace syncer 1209 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler_impl.cc ('k') | sync/engine/syncer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698