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

Side by Side Diff: components/bookmarks/browser/bookmark_model.h

Issue 299403005: Move BookmarkStorage into bookmarks namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | components/bookmarks/browser/bookmark_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "base/synchronization/waitable_event.h" 19 #include "base/synchronization/waitable_event.h"
20 #include "components/bookmarks/browser/bookmark_client.h" 20 #include "components/bookmarks/browser/bookmark_client.h"
21 #include "components/bookmarks/browser/bookmark_node.h" 21 #include "components/bookmarks/browser/bookmark_node.h"
22 #include "components/bookmarks/browser/bookmark_service.h" 22 #include "components/bookmarks/browser/bookmark_service.h"
23 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
24 #include "url/gurl.h" 24 #include "url/gurl.h"
25 25
26 class BookmarkExpandedStateTracker; 26 class BookmarkExpandedStateTracker;
27 class BookmarkIndex; 27 class BookmarkIndex;
28 class BookmarkLoadDetails;
29 class BookmarkModelObserver; 28 class BookmarkModelObserver;
30 class BookmarkStorage;
31 struct BookmarkMatch; 29 struct BookmarkMatch;
32 class PrefService; 30 class PrefService;
33 class ScopedGroupBookmarkActions; 31 class ScopedGroupBookmarkActions;
34 32
35 namespace base { 33 namespace base {
36 class FilePath; 34 class FilePath;
37 class SequencedTaskRunner; 35 class SequencedTaskRunner;
38 } 36 }
39 37
40 namespace bookmarks { 38 namespace bookmarks {
39 class BookmarkLoadDetails;
40 class BookmarkStorage;
41 class ScopedGroupBookmarkActions; 41 class ScopedGroupBookmarkActions;
42 } 42 }
43 43
44 namespace favicon_base { 44 namespace favicon_base {
45 struct FaviconImageResult; 45 struct FaviconImageResult;
46 } 46 }
47 47
48 namespace test { 48 namespace test {
49 class TestBookmarkClient; 49 class TestBookmarkClient;
50 } 50 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // Notify BookmarkModel that the favicons for |urls| have changed and have to 278 // Notify BookmarkModel that the favicons for |urls| have changed and have to
279 // be refetched. This notification is sent by BookmarkClient. 279 // be refetched. This notification is sent by BookmarkClient.
280 void OnFaviconChanged(const std::set<GURL>& urls); 280 void OnFaviconChanged(const std::set<GURL>& urls);
281 281
282 // Returns the client used by this BookmarkModel. 282 // Returns the client used by this BookmarkModel.
283 BookmarkClient* client() const { return client_; } 283 BookmarkClient* client() const { return client_; }
284 284
285 private: 285 private:
286 friend class BookmarkCodecTest; 286 friend class BookmarkCodecTest;
287 friend class BookmarkModelTest; 287 friend class BookmarkModelTest;
288 friend class BookmarkStorage; 288 friend class bookmarks::BookmarkStorage;
289 friend class bookmarks::ScopedGroupBookmarkActions; 289 friend class bookmarks::ScopedGroupBookmarkActions;
290 friend class test::TestBookmarkClient; 290 friend class test::TestBookmarkClient;
291 291
292 // Used to order BookmarkNodes by URL. 292 // Used to order BookmarkNodes by URL.
293 class NodeURLComparator { 293 class NodeURLComparator {
294 public: 294 public:
295 bool operator()(const BookmarkNode* n1, const BookmarkNode* n2) const { 295 bool operator()(const BookmarkNode* n1, const BookmarkNode* n2) const {
296 return n1->url() < n2->url(); 296 return n1->url() < n2->url();
297 } 297 }
298 }; 298 };
299 299
300 // Implementation of IsBookmarked. Before calling this the caller must obtain 300 // Implementation of IsBookmarked. Before calling this the caller must obtain
301 // a lock on |url_lock_|. 301 // a lock on |url_lock_|.
302 bool IsBookmarkedNoLock(const GURL& url); 302 bool IsBookmarkedNoLock(const GURL& url);
303 303
304 // Removes the node from internal maps and recurses through all children. If 304 // Removes the node from internal maps and recurses through all children. If
305 // the node is a url, its url is added to removed_urls. 305 // the node is a url, its url is added to removed_urls.
306 // 306 //
307 // This does NOT delete the node. 307 // This does NOT delete the node.
308 void RemoveNode(BookmarkNode* node, std::set<GURL>* removed_urls); 308 void RemoveNode(BookmarkNode* node, std::set<GURL>* removed_urls);
309 309
310 // Invoked when loading is finished. Sets |loaded_| and notifies observers. 310 // Invoked when loading is finished. Sets |loaded_| and notifies observers.
311 // BookmarkModel takes ownership of |details|. 311 // BookmarkModel takes ownership of |details|.
312 void DoneLoading(scoped_ptr<BookmarkLoadDetails> details); 312 void DoneLoading(scoped_ptr<bookmarks::BookmarkLoadDetails> details);
313 313
314 // Populates |nodes_ordered_by_url_set_| from root. 314 // Populates |nodes_ordered_by_url_set_| from root.
315 void PopulateNodesByURL(BookmarkNode* node); 315 void PopulateNodesByURL(BookmarkNode* node);
316 316
317 // Removes the node from its parent, but does not delete it. No notifications 317 // Removes the node from its parent, but does not delete it. No notifications
318 // are sent. |removed_urls| is populated with the urls which no longer have 318 // are sent. |removed_urls| is populated with the urls which no longer have
319 // any bookmarks associated with them. 319 // any bookmarks associated with them.
320 // This method should be called after acquiring |url_lock_|. 320 // This method should be called after acquiring |url_lock_|.
321 void RemoveNodeAndGetRemovedUrls(BookmarkNode* node, 321 void RemoveNodeAndGetRemovedUrls(BookmarkNode* node,
322 std::set<GURL>* removed_urls); 322 std::set<GURL>* removed_urls);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // Generates and returns the next node ID. 366 // Generates and returns the next node ID.
367 int64 generate_next_node_id(); 367 int64 generate_next_node_id();
368 368
369 // Sets the maximum node ID to the given value. 369 // Sets the maximum node ID to the given value.
370 // This is used by BookmarkCodec to report the maximum ID after it's done 370 // This is used by BookmarkCodec to report the maximum ID after it's done
371 // decoding since during decoding codec assigns node IDs. 371 // decoding since during decoding codec assigns node IDs.
372 void set_next_node_id(int64 id) { next_node_id_ = id; } 372 void set_next_node_id(int64 id) { next_node_id_ = id; }
373 373
374 // Creates and returns a new BookmarkLoadDetails. It's up to the caller to 374 // Creates and returns a new BookmarkLoadDetails. It's up to the caller to
375 // delete the returned object. 375 // delete the returned object.
376 scoped_ptr<BookmarkLoadDetails> CreateLoadDetails( 376 scoped_ptr<bookmarks::BookmarkLoadDetails> CreateLoadDetails(
377 const std::string& accept_languages); 377 const std::string& accept_languages);
378 378
379 BookmarkClient* const client_; 379 BookmarkClient* const client_;
380 380
381 // Whether the initial set of data has been loaded. 381 // Whether the initial set of data has been loaded.
382 bool loaded_; 382 bool loaded_;
383 383
384 // The root node. This contains the bookmark bar node, the 'other' node and 384 // The root node. This contains the bookmark bar node, the 'other' node and
385 // the mobile node as children. 385 // the mobile node as children.
386 BookmarkNode root_; 386 BookmarkNode root_;
(...skipping 13 matching lines...) Expand all
400 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As 400 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As
401 // such, be sure and wrap all usage of it around |url_lock_|. 401 // such, be sure and wrap all usage of it around |url_lock_|.
402 typedef std::multiset<BookmarkNode*, NodeURLComparator> NodesOrderedByURLSet; 402 typedef std::multiset<BookmarkNode*, NodeURLComparator> NodesOrderedByURLSet;
403 NodesOrderedByURLSet nodes_ordered_by_url_set_; 403 NodesOrderedByURLSet nodes_ordered_by_url_set_;
404 base::Lock url_lock_; 404 base::Lock url_lock_;
405 405
406 // Used for loading favicons. 406 // Used for loading favicons.
407 base::CancelableTaskTracker cancelable_task_tracker_; 407 base::CancelableTaskTracker cancelable_task_tracker_;
408 408
409 // Reads/writes bookmarks to disk. 409 // Reads/writes bookmarks to disk.
410 scoped_refptr<BookmarkStorage> store_; 410 scoped_refptr<bookmarks::BookmarkStorage> store_;
411 411
412 scoped_ptr<BookmarkIndex> index_; 412 scoped_ptr<BookmarkIndex> index_;
413 413
414 // True if URLs are stored in the BookmarkIndex in addition to bookmark 414 // True if URLs are stored in the BookmarkIndex in addition to bookmark
415 // titles. 415 // titles.
416 const bool index_urls_; 416 const bool index_urls_;
417 417
418 base::WaitableEvent loaded_signal_; 418 base::WaitableEvent loaded_signal_;
419 419
420 // See description of IsDoingExtensiveChanges above. 420 // See description of IsDoingExtensiveChanges above.
421 int extensive_changes_; 421 int extensive_changes_;
422 422
423 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; 423 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_;
424 424
425 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); 425 DISALLOW_COPY_AND_ASSIGN(BookmarkModel);
426 }; 426 };
427 427
428 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ 428 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_
OLDNEW
« no previous file with comments | « no previous file | components/bookmarks/browser/bookmark_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698