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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_ANDROID_PROVIDER_BOOKMARK_MODEL_OBSERVER_TASK_H_ 6 #define CHROME_BROWSER_ANDROID_PROVIDER_BOOKMARK_MODEL_OBSERVER_TASK_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "chrome/browser/bookmarks/bookmark_model_observer.h" 11 12 // Base class for synchronous tasks that involve the bookmark model. 13 // Ensures the model has been loaded before accessing it. 14 // Must not be created from the UI thread. 15 class BookmarkModelTask { 16 public: 17 explicit BookmarkModelTask(BookmarkModel* model); 18 BookmarkModel* model() const; 19 20 private: 21 BookmarkModel* model_; 22 23 DISALLOW_COPY_AND_ASSIGN(BookmarkModelTask); 24 }; 25 26 // Base class for bookmark model tasks that observe for model updates. 27 class BookmarkModelObserverTask : public BookmarkModelTask, 28 public BookmarkModelObserver { 29 public: 30 explicit BookmarkModelObserverTask(BookmarkModel* bookmark_model); 31 virtual ~BookmarkModelObserverTask(); 32 33 // BookmarkModelObserver: 34 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE; 35 virtual void BookmarkNodeMoved(BookmarkModel* model, 36 const BookmarkNode* old_parent, 37 int old_index, 38 const BookmarkNode* new_parent, 39 int new_index) OVERRIDE; 40 virtual void BookmarkNodeAdded(BookmarkModel* model, 41 const BookmarkNode* parent, 42 int index) OVERRIDE; 43 virtual void BookmarkNodeRemoved(BookmarkModel* model, 44 const BookmarkNode* parent, 45 int old_index, 46 const BookmarkNode* node) OVERRIDE; 47 virtual void BookmarkAllNodesRemoved(BookmarkModel* model) OVERRIDE; 48 virtual void BookmarkNodeChanged(BookmarkModel* model, 49 const BookmarkNode* node) OVERRIDE; 50 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model, 51 const BookmarkNode* node) OVERRIDE; 52 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, 53 const BookmarkNode* node) OVERRIDE; 54 55 private: 56 DISALLOW_COPY_AND_ASSIGN(BookmarkModelObserverTask); 57 }; 58 59 #endif // CHROME_BROWSER_ANDROID_PROVIDER_BOOKMARK_MODEL_OBSERVER_TASK_H_ 60