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

Side by Side Diff: chrome/browser/sync/engine/process_commit_response_command_unittest.cc

Issue 8638001: [Sync] Made some sync session member functions const (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix latent bug in StatusController Created 9 years, 1 month 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 <vector> 5 #include <vector>
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "chrome/browser/sync/engine/process_commit_response_command.h" 9 #include "chrome/browser/sync/engine/process_commit_response_command.h"
10 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 10 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 120
121 // Create a new unsynced item in the database, and synthesize a commit 121 // Create a new unsynced item in the database, and synthesize a commit
122 // record and a commit response for it in the syncer session. If item_id 122 // record and a commit response for it in the syncer session. If item_id
123 // is a local ID, the item will be a create operation. Otherwise, it 123 // is a local ID, the item will be a create operation. Otherwise, it
124 // will be an edit. 124 // will be an edit.
125 void CreateUnprocessedCommitResult(const Id& item_id, 125 void CreateUnprocessedCommitResult(const Id& item_id,
126 const Id& parent_id, 126 const Id& parent_id,
127 const string& name, 127 const string& name,
128 syncable::ModelType model_type) { 128 syncable::ModelType model_type) {
129 sessions::StatusController* sync_state = session()->status_controller(); 129 sessions::StatusController* sync_state =
130 session()->mutable_status_controller();
130 bool is_folder = true; 131 bool is_folder = true;
131 int64 metahandle = 0; 132 int64 metahandle = 0;
132 CreateUnsyncedItem(item_id, parent_id, name, is_folder, model_type, 133 CreateUnsyncedItem(item_id, parent_id, name, is_folder, model_type,
133 &metahandle); 134 &metahandle);
134 135
135 // ProcessCommitResponseCommand consumes commit_ids from the session 136 // ProcessCommitResponseCommand consumes commit_ids from the session
136 // state, so we need to update that. O(n^2) because it's a test. 137 // state, so we need to update that. O(n^2) because it's a test.
137 commit_set_->AddCommitItem(metahandle, item_id, model_type); 138 commit_set_->AddCommitItem(metahandle, item_id, model_type);
138 sync_state->set_commit_set(*commit_set_.get()); 139 sync_state->set_commit_set(*commit_set_.get());
139 140
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 for (int i = 0; i < commit->commit().entries_size(); ++i) { 181 for (int i = 0; i < commit->commit().entries_size(); ++i) {
181 if (commit->commit().entries(i).id_string() == 182 if (commit->commit().entries(i).id_string() ==
182 entity->parent_id_string()) { 183 entity->parent_id_string()) {
183 entry_response->set_parent_id_string( 184 entry_response->set_parent_id_string(
184 response->commit().entryresponse(i).id_string()); 185 response->commit().entryresponse(i).id_string());
185 } 186 }
186 } 187 }
187 } 188 }
188 189
189 void SetLastErrorCode(CommitResponse::ResponseType error_code) { 190 void SetLastErrorCode(CommitResponse::ResponseType error_code) {
190 sessions::StatusController* sync_state = session()->status_controller(); 191 sessions::StatusController* sync_state =
192 session()->mutable_status_controller();
191 sync_pb::ClientToServerResponse* response = 193 sync_pb::ClientToServerResponse* response =
192 sync_state->mutable_commit_response(); 194 sync_state->mutable_commit_response();
193 sync_pb::CommitResponse_EntryResponse* entry_response = 195 sync_pb::CommitResponse_EntryResponse* entry_response =
194 response->mutable_commit()->mutable_entryresponse( 196 response->mutable_commit()->mutable_entryresponse(
195 response->mutable_commit()->entryresponse_size() - 1); 197 response->mutable_commit()->entryresponse_size() - 1);
196 entry_response->set_response_type(error_code); 198 entry_response->set_response_type(error_code);
197 } 199 }
198 200
199 ProcessCommitResponseCommand command_; 201 ProcessCommitResponseCommand command_;
200 TestIdFactory id_factory_; 202 TestIdFactory id_factory_;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 441 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
440 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 442 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
441 } else { 443 } else {
442 EXPECT_TRUE(final_monitor_records.empty()) 444 EXPECT_TRUE(final_monitor_records.empty())
443 << "Should not restore records after successful bookmark commit."; 445 << "Should not restore records after successful bookmark commit.";
444 } 446 }
445 } 447 }
446 448
447 449
448 } // namespace browser_sync 450 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/process_commit_response_command.cc ('k') | chrome/browser/sync/engine/process_updates_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698