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

Side by Side Diff: chrome/browser/sync/sessions/test_util.cc

Issue 9036003: Avoid useless SYNC_CYCLE_CONTINUATION sync cycle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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) 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 #include "chrome/browser/sync/sessions/test_util.h" 5 #include "chrome/browser/sync/sessions/test_util.h"
6 6
7 namespace browser_sync { 7 namespace browser_sync {
8 namespace sessions { 8 namespace sessions {
9 namespace test_util { 9 namespace test_util {
10 10
11 void SimulateHasMoreToSync(sessions::SyncSession* session, 11 void SimulateHasMoreToSync(sessions::SyncSession* session,
12 SyncerStep begin, SyncerStep end) { 12 SyncerStep begin, SyncerStep end) {
13 session->mutable_status_controller()->update_conflicts_resolved(true); 13 session->mutable_status_controller()->update_conflicts_resolved(true);
14 ASSERT_TRUE(session->HasMoreToSync()); 14 ASSERT_TRUE(session->HasMoreToSync());
15 } 15 }
16 16
17 void SimulateDownloadUpdatesFailed(sessions::SyncSession* session, 17 void SimulateDownloadUpdatesFailed(sessions::SyncSession* session,
18 SyncerStep begin, SyncerStep end) { 18 SyncerStep begin, SyncerStep end) {
19 // Note that a non-zero value of changes_remaining once a session has 19 session->mutable_status_controller()->set_download_updates_result(
20 // completed implies that the Syncer was unable to exhaust this count during 20 SERVER_RETURN_TRANSIENT_ERROR);
21 // the GetUpdates cycle. This is an indication that an error occurred.
22 session->mutable_status_controller()->set_num_server_changes_remaining(1);
23 } 21 }
24 22
25 void SimulateCommitFailed(sessions::SyncSession* session, 23 void SimulateCommitFailed(sessions::SyncSession* session,
26 SyncerStep begin, SyncerStep end) { 24 SyncerStep begin, SyncerStep end) {
27 // Note that a non-zero number of unsynced handles once a session has 25 session->mutable_status_controller()->set_post_commit_result(
28 // completed implies that the Syncer was unable to make forward progress 26 SERVER_RETURN_TRANSIENT_ERROR);
29 // during a commit, indicating an error occurred.
30 // See implementation of SyncSession::HasMoreToSync.
31 std::vector<int64> handles;
32 handles.push_back(1);
33 session->mutable_status_controller()->set_unsynced_handles(handles);
34 } 27 }
35 28
36 void SimulateSuccess(sessions::SyncSession* session, 29 void SimulateSuccess(sessions::SyncSession* session,
37 SyncerStep begin, SyncerStep end) { 30 SyncerStep begin, SyncerStep end) {
38 if (session->HasMoreToSync()) { 31 if (session->HasMoreToSync()) {
39 ADD_FAILURE() << "Shouldn't have more to sync"; 32 ADD_FAILURE() << "Shouldn't have more to sync";
40 } 33 }
41 ASSERT_EQ(0U, session->status_controller().num_server_changes_remaining()); 34 ASSERT_EQ(0U, session->status_controller().num_server_changes_remaining());
42 ASSERT_EQ(0U, session->status_controller().unsynced_handles().size()); 35 ASSERT_EQ(0U, session->status_controller().unsynced_handles().size());
43 } 36 }
44 37
45 void SimulateThrottledImpl(sessions::SyncSession* session, 38 void SimulateThrottledImpl(sessions::SyncSession* session,
46 const base::TimeDelta& delta) { 39 const base::TimeDelta& delta) {
47 session->delegate()->OnSilencedUntil(base::TimeTicks::Now() + delta); 40 session->delegate()->OnSilencedUntil(base::TimeTicks::Now() + delta);
48 } 41 }
49 42
50 void SimulatePollIntervalUpdateImpl(sessions::SyncSession* session, 43 void SimulatePollIntervalUpdateImpl(sessions::SyncSession* session,
51 const base::TimeDelta& new_poll) { 44 const base::TimeDelta& new_poll) {
52 session->delegate()->OnReceivedLongPollIntervalUpdate(new_poll); 45 session->delegate()->OnReceivedLongPollIntervalUpdate(new_poll);
53 } 46 }
54 47
55 void SimulateSessionsCommitDelayUpdateImpl(sessions::SyncSession* session, 48 void SimulateSessionsCommitDelayUpdateImpl(sessions::SyncSession* session,
56 const base::TimeDelta& new_delay) { 49 const base::TimeDelta& new_delay) {
57 session->delegate()->OnReceivedSessionsCommitDelay(new_delay); 50 session->delegate()->OnReceivedSessionsCommitDelay(new_delay);
58 } 51 }
59 52
60 } // namespace test_util 53 } // namespace test_util
61 } // namespace sessions 54 } // namespace sessions
62 } // namespace browser_sync 55 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/sessions/sync_session.cc ('k') | chrome/browser/sync/test/engine/fake_model_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698