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

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

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 years, 2 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 (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 #ifndef COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_CHANGE_PROCESSOR_H_ 5 #ifndef COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_CHANGE_PROCESSOR_H_
6 #define COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_CHANGE_PROCESSOR_H_ 6 #define COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_CHANGE_PROCESSOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "components/bookmarks/browser/bookmark_model_observer.h" 17 #include "components/bookmarks/browser/bookmark_model_observer.h"
18 #include "components/bookmarks/browser/bookmark_node.h" 18 #include "components/bookmarks/browser/bookmark_node.h"
19 #include "components/sync/api/data_type_error_handler.h" 19 #include "components/sync/api/data_type_error_handler.h"
20 #include "components/sync/driver/change_processor.h" 20 #include "components/sync/driver/change_processor.h"
21 #include "components/sync_bookmarks/bookmark_model_associator.h" 21 #include "components/sync_bookmarks/bookmark_model_associator.h"
22 22
23 class Profile; 23 class Profile;
24 24
25 namespace base { 25 namespace base {
26 class RefCountedMemory; 26 class RefCountedMemory;
27 } 27 } // namespace base
28 28
29 namespace syncer { 29 namespace syncer {
30 class SyncClient;
30 class WriteNode; 31 class WriteNode;
31 class WriteTransaction; 32 class WriteTransaction;
32 } // namespace syncer 33 } // namespace syncer
33 34
34 namespace sync_driver {
35 class SyncClient;
36 }
37
38 namespace sync_bookmarks { 35 namespace sync_bookmarks {
39 36
40 // This class is responsible for taking changes from the BookmarkModel 37 // This class is responsible for taking changes from the BookmarkModel
41 // and applying them to the sync API 'syncable' model, and vice versa. 38 // and applying them to the sync API 'syncable' model, and vice versa.
42 // All operations and use of this class are from the UI thread. 39 // All operations and use of this class are from the UI thread.
43 // This is currently bookmarks specific. 40 // This is currently bookmarks specific.
44 class BookmarkChangeProcessor : public bookmarks::BookmarkModelObserver, 41 class BookmarkChangeProcessor : public bookmarks::BookmarkModelObserver,
45 public sync_driver::ChangeProcessor { 42 public syncer::ChangeProcessor {
46 public: 43 public:
47 BookmarkChangeProcessor( 44 BookmarkChangeProcessor(
48 sync_driver::SyncClient* sync_client, 45 syncer::SyncClient* sync_client,
49 BookmarkModelAssociator* model_associator, 46 BookmarkModelAssociator* model_associator,
50 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler); 47 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler);
51 ~BookmarkChangeProcessor() override; 48 ~BookmarkChangeProcessor() override;
52 49
53 // bookmarks::BookmarkModelObserver: 50 // bookmarks::BookmarkModelObserver:
54 // BookmarkModel -> sync API model change application. 51 // BookmarkModel -> sync API model change application.
55 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, 52 void BookmarkModelLoaded(bookmarks::BookmarkModel* model,
56 bool ids_reassigned) override; 53 bool ids_reassigned) override;
57 void BookmarkModelBeingDeleted(bookmarks::BookmarkModel* model) override; 54 void BookmarkModelBeingDeleted(bookmarks::BookmarkModel* model) override;
58 void BookmarkNodeMoved(bookmarks::BookmarkModel* model, 55 void BookmarkNodeMoved(bookmarks::BookmarkModel* model,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 90
94 // The following methods are static and hence may be invoked at any time, and 91 // The following methods are static and hence may be invoked at any time, and
95 // do not depend on having a running ChangeProcessor. 92 // do not depend on having a running ChangeProcessor.
96 // TODO(stanisc): considier refactoring these methods out of this class. 93 // TODO(stanisc): considier refactoring these methods out of this class.
97 94
98 // Updates the title, URL, creation time and favicon of the bookmark |node| 95 // Updates the title, URL, creation time and favicon of the bookmark |node|
99 // with data taken from the |sync_node| sync node. 96 // with data taken from the |sync_node| sync node.
100 static void UpdateBookmarkWithSyncData(const syncer::BaseNode& sync_node, 97 static void UpdateBookmarkWithSyncData(const syncer::BaseNode& sync_node,
101 bookmarks::BookmarkModel* model, 98 bookmarks::BookmarkModel* model,
102 const bookmarks::BookmarkNode* node, 99 const bookmarks::BookmarkNode* node,
103 sync_driver::SyncClient* sync_client); 100 syncer::SyncClient* sync_client);
104 101
105 // Creates a bookmark node under the given parent node from the given sync 102 // Creates a bookmark node under the given parent node from the given sync
106 // node. Returns the newly created node. The created node is placed at the 103 // node. Returns the newly created node. The created node is placed at the
107 // specified index among the parent's children. 104 // specified index among the parent's children.
108 static const bookmarks::BookmarkNode* CreateBookmarkNode( 105 static const bookmarks::BookmarkNode* CreateBookmarkNode(
109 const syncer::BaseNode* sync_node, 106 const syncer::BaseNode* sync_node,
110 const bookmarks::BookmarkNode* parent, 107 const bookmarks::BookmarkNode* parent,
111 bookmarks::BookmarkModel* model, 108 bookmarks::BookmarkModel* model,
112 sync_driver::SyncClient* sync_client, 109 syncer::SyncClient* sync_client,
113 int index); 110 int index);
114 111
115 // Overload of CreateBookmarkNode function above that helps to avoid 112 // Overload of CreateBookmarkNode function above that helps to avoid
116 // converting / parsing the bookmark title and URL multiple times. 113 // converting / parsing the bookmark title and URL multiple times.
117 static const bookmarks::BookmarkNode* CreateBookmarkNode( 114 static const bookmarks::BookmarkNode* CreateBookmarkNode(
118 const base::string16& title, 115 const base::string16& title,
119 const GURL& url, 116 const GURL& url,
120 const syncer::BaseNode* sync_node, 117 const syncer::BaseNode* sync_node,
121 const bookmarks::BookmarkNode* parent, 118 const bookmarks::BookmarkNode* parent,
122 bookmarks::BookmarkModel* model, 119 bookmarks::BookmarkModel* model,
123 sync_driver::SyncClient* sync_client, 120 syncer::SyncClient* sync_client,
124 int index); 121 int index);
125 122
126 // Sets the favicon of the given bookmark node from the given sync node. 123 // Sets the favicon of the given bookmark node from the given sync node.
127 // Returns whether the favicon was set in the bookmark node. 124 // Returns whether the favicon was set in the bookmark node.
128 // |profile| is the profile that contains the HistoryService and BookmarkModel 125 // |profile| is the profile that contains the HistoryService and BookmarkModel
129 // for the bookmark in question. 126 // for the bookmark in question.
130 static bool SetBookmarkFavicon(const syncer::BaseNode* sync_node, 127 static bool SetBookmarkFavicon(const syncer::BaseNode* sync_node,
131 const bookmarks::BookmarkNode* bookmark_node, 128 const bookmarks::BookmarkNode* bookmark_node,
132 bookmarks::BookmarkModel* model, 129 bookmarks::BookmarkModel* model,
133 sync_driver::SyncClient* sync_client); 130 syncer::SyncClient* sync_client);
134 131
135 // Applies the 1x favicon |bitmap_data| and |icon_url| to |bookmark_node|. 132 // Applies the 1x favicon |bitmap_data| and |icon_url| to |bookmark_node|.
136 // |profile| is the profile that contains the HistoryService and BookmarkModel 133 // |profile| is the profile that contains the HistoryService and BookmarkModel
137 // for the bookmark in question. 134 // for the bookmark in question.
138 static void ApplyBookmarkFavicon( 135 static void ApplyBookmarkFavicon(
139 const bookmarks::BookmarkNode* bookmark_node, 136 const bookmarks::BookmarkNode* bookmark_node,
140 sync_driver::SyncClient* sync_client, 137 syncer::SyncClient* sync_client,
141 const GURL& icon_url, 138 const GURL& icon_url,
142 const scoped_refptr<base::RefCountedMemory>& bitmap_data); 139 const scoped_refptr<base::RefCountedMemory>& bitmap_data);
143 140
144 // Sets the favicon of the given sync node from the given bookmark node. 141 // Sets the favicon of the given sync node from the given bookmark node.
145 static void SetSyncNodeFavicon(const bookmarks::BookmarkNode* bookmark_node, 142 static void SetSyncNodeFavicon(const bookmarks::BookmarkNode* bookmark_node,
146 bookmarks::BookmarkModel* model, 143 bookmarks::BookmarkModel* model,
147 syncer::WriteNode* sync_node); 144 syncer::WriteNode* sync_node);
148 145
149 // Treat the |index|th child of |parent| as a newly added node, and create a 146 // Treat the |index|th child of |parent| as a newly added node, and create a
150 // corresponding node in the sync domain using |trans|. All properties 147 // corresponding node in the sync domain using |trans|. All properties
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 240
244 // Returns false if |node| should not be synced. 241 // Returns false if |node| should not be synced.
245 bool CanSyncNode(const bookmarks::BookmarkNode* node); 242 bool CanSyncNode(const bookmarks::BookmarkNode* node);
246 243
247 base::ThreadChecker thread_checker_; 244 base::ThreadChecker thread_checker_;
248 245
249 // The bookmark model we are processing changes from. Non-NULL when 246 // The bookmark model we are processing changes from. Non-NULL when
250 // |running_| is true. 247 // |running_| is true.
251 bookmarks::BookmarkModel* bookmark_model_; 248 bookmarks::BookmarkModel* bookmark_model_;
252 249
253 sync_driver::SyncClient* sync_client_; 250 syncer::SyncClient* sync_client_;
254 251
255 // The two models should be associated according to this ModelAssociator. 252 // The two models should be associated according to this ModelAssociator.
256 BookmarkModelAssociator* model_associator_; 253 BookmarkModelAssociator* model_associator_;
257 254
258 DISALLOW_COPY_AND_ASSIGN(BookmarkChangeProcessor); 255 DISALLOW_COPY_AND_ASSIGN(BookmarkChangeProcessor);
259 }; 256 };
260 257
261 } // namespace sync_bookmarks 258 } // namespace sync_bookmarks
262 259
263 #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_CHANGE_PROCESSOR_H_ 260 #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_CHANGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « components/sync/tools/sync_listen_notifications.cc ('k') | components/sync_bookmarks/bookmark_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698