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

Side by Side Diff: components/sync_bookmarks/bookmark_change_processor.cc

Issue 1966023002: [Sync] Move DataTypeErrorHandler to //sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Found an unsaved buffer :( Created 4 years, 7 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/sync_bookmarks/bookmark_change_processor.h" 5 #include "components/sync_bookmarks/bookmark_change_processor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <stack> 10 #include <stack>
(...skipping 27 matching lines...) Expand all
38 using syncer::ChangeRecord; 38 using syncer::ChangeRecord;
39 using syncer::ChangeRecordList; 39 using syncer::ChangeRecordList;
40 40
41 namespace browser_sync { 41 namespace browser_sync {
42 42
43 static const char kMobileBookmarksTag[] = "synced_bookmarks"; 43 static const char kMobileBookmarksTag[] = "synced_bookmarks";
44 44
45 BookmarkChangeProcessor::BookmarkChangeProcessor( 45 BookmarkChangeProcessor::BookmarkChangeProcessor(
46 sync_driver::SyncClient* sync_client, 46 sync_driver::SyncClient* sync_client,
47 BookmarkModelAssociator* model_associator, 47 BookmarkModelAssociator* model_associator,
48 sync_driver::DataTypeErrorHandler* error_handler) 48 syncer::DataTypeErrorHandler* error_handler)
49 : sync_driver::ChangeProcessor(error_handler), 49 : sync_driver::ChangeProcessor(error_handler),
50 bookmark_model_(NULL), 50 bookmark_model_(NULL),
51 sync_client_(sync_client), 51 sync_client_(sync_client),
52 model_associator_(model_associator) { 52 model_associator_(model_associator) {
53 DCHECK(model_associator); 53 DCHECK(model_associator);
54 DCHECK(sync_client); 54 DCHECK(sync_client);
55 DCHECK(error_handler); 55 DCHECK(error_handler);
56 } 56 }
57 57
58 BookmarkChangeProcessor::~BookmarkChangeProcessor() { 58 BookmarkChangeProcessor::~BookmarkChangeProcessor() {
59 if (bookmark_model_) 59 if (bookmark_model_)
60 bookmark_model_->RemoveObserver(this); 60 bookmark_model_->RemoveObserver(this);
61 } 61 }
62 62
63 void BookmarkChangeProcessor::StartImpl() { 63 void BookmarkChangeProcessor::StartImpl() {
64 DCHECK(thread_checker_.CalledOnValidThread()); 64 DCHECK(thread_checker_.CalledOnValidThread());
65 DCHECK(!bookmark_model_); 65 DCHECK(!bookmark_model_);
66 bookmark_model_ = sync_client_->GetBookmarkModel(); 66 bookmark_model_ = sync_client_->GetBookmarkModel();
67 DCHECK(bookmark_model_->loaded()); 67 DCHECK(bookmark_model_->loaded());
68 bookmark_model_->AddObserver(this); 68 bookmark_model_->AddObserver(this);
69 } 69 }
70 70
71 void BookmarkChangeProcessor::UpdateSyncNodeProperties( 71 void BookmarkChangeProcessor::UpdateSyncNodeProperties(
72 const BookmarkNode* src, 72 const BookmarkNode* src,
73 BookmarkModel* model, 73 BookmarkModel* model,
74 syncer::WriteNode* dst, 74 syncer::WriteNode* dst,
75 sync_driver::DataTypeErrorHandler* error_handler) { 75 syncer::DataTypeErrorHandler* error_handler) {
76 // Set the properties of the item. 76 // Set the properties of the item.
77 dst->SetIsFolder(src->is_folder()); 77 dst->SetIsFolder(src->is_folder());
78 dst->SetTitle(base::UTF16ToUTF8(src->GetTitle())); 78 dst->SetTitle(base::UTF16ToUTF8(src->GetTitle()));
79 sync_pb::BookmarkSpecifics bookmark_specifics(dst->GetBookmarkSpecifics()); 79 sync_pb::BookmarkSpecifics bookmark_specifics(dst->GetBookmarkSpecifics());
80 if (!src->is_folder()) { 80 if (!src->is_folder()) {
81 if (!src->url().is_valid()) { 81 if (!src->url().is_valid()) {
82 // Report the invalid URL and continue. 82 // Report the invalid URL and continue.
83 // TODO(stanisc): crbug/482155: Revisit this once the root cause for 83 // TODO(stanisc): crbug/482155: Revisit this once the root cause for
84 // invalid URLs is understood. 84 // invalid URLs is understood.
85 error_handler->CreateAndUploadError( 85 error_handler->CreateAndUploadError(
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 CreateOrUpdateSyncNode(node); 292 CreateOrUpdateSyncNode(node);
293 } 293 }
294 294
295 // static 295 // static
296 int64_t BookmarkChangeProcessor::CreateSyncNode( 296 int64_t BookmarkChangeProcessor::CreateSyncNode(
297 const BookmarkNode* parent, 297 const BookmarkNode* parent,
298 BookmarkModel* model, 298 BookmarkModel* model,
299 int index, 299 int index,
300 syncer::WriteTransaction* trans, 300 syncer::WriteTransaction* trans,
301 BookmarkModelAssociator* associator, 301 BookmarkModelAssociator* associator,
302 sync_driver::DataTypeErrorHandler* error_handler) { 302 syncer::DataTypeErrorHandler* error_handler) {
303 const BookmarkNode* child = parent->GetChild(index); 303 const BookmarkNode* child = parent->GetChild(index);
304 DCHECK(child); 304 DCHECK(child);
305 305
306 // Create a WriteNode container to hold the new node. 306 // Create a WriteNode container to hold the new node.
307 syncer::WriteNode sync_child(trans); 307 syncer::WriteNode sync_child(trans);
308 308
309 // Actually create the node with the appropriate initial position. 309 // Actually create the node with the appropriate initial position.
310 if (!PlaceSyncNode(CREATE, parent, index, trans, &sync_child, associator)) { 310 if (!PlaceSyncNode(CREATE, parent, index, trans, &sync_child, associator)) {
311 syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, 311 syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
312 "Failed to create sync node.", syncer::BOOKMARKS); 312 "Failed to create sync node.", syncer::BOOKMARKS);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 359 }
360 CreateOrUpdateSyncNode(node); 360 CreateOrUpdateSyncNode(node);
361 } 361 }
362 362
363 // Static. 363 // Static.
364 int64_t BookmarkChangeProcessor::UpdateSyncNode( 364 int64_t BookmarkChangeProcessor::UpdateSyncNode(
365 const BookmarkNode* node, 365 const BookmarkNode* node,
366 BookmarkModel* model, 366 BookmarkModel* model,
367 syncer::WriteTransaction* trans, 367 syncer::WriteTransaction* trans,
368 BookmarkModelAssociator* associator, 368 BookmarkModelAssociator* associator,
369 sync_driver::DataTypeErrorHandler* error_handler) { 369 syncer::DataTypeErrorHandler* error_handler) {
370 // Lookup the sync node that's associated with |node|. 370 // Lookup the sync node that's associated with |node|.
371 syncer::WriteNode sync_node(trans); 371 syncer::WriteNode sync_node(trans);
372 if (!associator->InitSyncNodeFromChromeId(node->id(), &sync_node)) { 372 if (!associator->InitSyncNodeFromChromeId(node->id(), &sync_node)) {
373 syncer::SyncError error(FROM_HERE, 373 syncer::SyncError error(FROM_HERE,
374 syncer::SyncError::DATATYPE_ERROR, 374 syncer::SyncError::DATATYPE_ERROR,
375 "Failed to init sync node from chrome node", 375 "Failed to init sync node from chrome node",
376 syncer::BOOKMARKS); 376 syncer::BOOKMARKS);
377 error_handler->OnSingleDataTypeUnrecoverableError(error); 377 error_handler->OnSingleDataTypeUnrecoverableError(error);
378 return syncer::kInvalidId; 378 return syncer::kInvalidId;
379 } 379 }
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 updated_specifics.set_icon_url(bookmark_node->icon_url().spec()); 971 updated_specifics.set_icon_url(bookmark_node->icon_url().spec());
972 sync_node->SetBookmarkSpecifics(updated_specifics); 972 sync_node->SetBookmarkSpecifics(updated_specifics);
973 } 973 }
974 } 974 }
975 975
976 bool BookmarkChangeProcessor::CanSyncNode(const BookmarkNode* node) { 976 bool BookmarkChangeProcessor::CanSyncNode(const BookmarkNode* node) {
977 return bookmark_model_->client()->CanSyncNode(node); 977 return bookmark_model_->client()->CanSyncNode(node);
978 } 978 }
979 979
980 } // namespace browser_sync 980 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/sync_bookmarks/bookmark_change_processor.h ('k') | components/sync_bookmarks/bookmark_model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698