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

Side by Side Diff: chrome/browser/sync/glue/generic_change_processor.cc

Issue 10690128: Reland r145993. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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) 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 "chrome/browser/sync/glue/generic_change_processor.h" 5 #include "chrome/browser/sync/glue/generic_change_processor.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const syncer::BaseTransaction* trans, 42 const syncer::BaseTransaction* trans,
43 const syncer::ImmutableChangeRecordList& changes) { 43 const syncer::ImmutableChangeRecordList& changes) {
44 DCHECK(CalledOnValidThread()); 44 DCHECK(CalledOnValidThread());
45 DCHECK(running()); 45 DCHECK(running());
46 DCHECK(syncer_changes_.empty()); 46 DCHECK(syncer_changes_.empty());
47 for (syncer::ChangeRecordList::const_iterator it = 47 for (syncer::ChangeRecordList::const_iterator it =
48 changes.Get().begin(); it != changes.Get().end(); ++it) { 48 changes.Get().begin(); it != changes.Get().end(); ++it) {
49 if (it->action == syncer::ChangeRecord::ACTION_DELETE) { 49 if (it->action == syncer::ChangeRecord::ACTION_DELETE) {
50 syncer_changes_.push_back( 50 syncer_changes_.push_back(
51 syncer::SyncChange( 51 syncer::SyncChange(
52 FROM_HERE,
52 syncer::SyncChange::ACTION_DELETE, 53 syncer::SyncChange::ACTION_DELETE,
53 syncer::SyncData::CreateRemoteData(it->id, it->specifics))); 54 syncer::SyncData::CreateRemoteData(it->id, it->specifics)));
54 } else { 55 } else {
55 syncer::SyncChange::SyncChangeType action = 56 syncer::SyncChange::SyncChangeType action =
56 (it->action == syncer::ChangeRecord::ACTION_ADD) ? 57 (it->action == syncer::ChangeRecord::ACTION_ADD) ?
57 syncer::SyncChange::ACTION_ADD : syncer::SyncChange::ACTION_UPDATE; 58 syncer::SyncChange::ACTION_ADD : syncer::SyncChange::ACTION_UPDATE;
58 // Need to load specifics from node. 59 // Need to load specifics from node.
59 syncer::ReadNode read_node(trans); 60 syncer::ReadNode read_node(trans);
60 if (read_node.InitByIdLookup(it->id) != syncer::BaseNode::INIT_OK) { 61 if (read_node.InitByIdLookup(it->id) != syncer::BaseNode::INIT_OK) {
61 error_handler()->OnSingleDatatypeUnrecoverableError( 62 error_handler()->OnSingleDatatypeUnrecoverableError(
62 FROM_HERE, 63 FROM_HERE,
63 "Failed to look up data for received change with id " + 64 "Failed to look up data for received change with id " +
64 base::Int64ToString(it->id)); 65 base::Int64ToString(it->id));
65 return; 66 return;
66 } 67 }
67 syncer_changes_.push_back( 68 syncer_changes_.push_back(
68 syncer::SyncChange(action, 69 syncer::SyncChange(
69 syncer::SyncData::CreateRemoteData( 70 FROM_HERE,
70 it->id, read_node.GetEntitySpecifics()))); 71 action,
72 syncer::SyncData::CreateRemoteData(
73 it->id, read_node.GetEntitySpecifics())));
71 } 74 }
72 } 75 }
73 } 76 }
74 77
75 void GenericChangeProcessor::CommitChangesFromSyncModel() { 78 void GenericChangeProcessor::CommitChangesFromSyncModel() {
76 DCHECK(CalledOnValidThread()); 79 DCHECK(CalledOnValidThread());
77 if (!running()) 80 if (!running())
78 return; 81 return;
79 if (syncer_changes_.empty()) 82 if (syncer_changes_.empty())
80 return; 83 return;
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 void GenericChangeProcessor::StopImpl() { 480 void GenericChangeProcessor::StopImpl() {
478 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 481 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
479 } 482 }
480 483
481 syncer::UserShare* GenericChangeProcessor::share_handle() const { 484 syncer::UserShare* GenericChangeProcessor::share_handle() const {
482 DCHECK(CalledOnValidThread()); 485 DCHECK(CalledOnValidThread());
483 return share_handle_; 486 return share_handle_;
484 } 487 }
485 488
486 } // namespace browser_sync 489 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698