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.
5 #ifndef CHROME_BROWSER_ANDROID_PROVIDER_BOOKMARK_MODEL_OBSERVER_TASK_H_
6 #define CHROME_BROWSER_ANDROID_PROVIDER_BOOKMARK_MODEL_OBSERVER_TASK_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
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
{
17 explicit BookmarkModelTask(BookmarkModel
* model
);
18 BookmarkModel
* model() const;
21 BookmarkModel
* model_
;
23 DISALLOW_COPY_AND_ASSIGN(BookmarkModelTask
);
26 // Base class for bookmark model tasks that observe for model updates.
27 class BookmarkModelObserverTask
: public BookmarkModelTask
,
28 public BookmarkModelObserver
{
30 explicit BookmarkModelObserverTask(BookmarkModel
* bookmark_model
);
31 virtual ~BookmarkModelObserverTask();
33 // BookmarkModelObserver:
34 virtual void Loaded(BookmarkModel
* model
, bool ids_reassigned
) OVERRIDE
;
35 virtual void BookmarkNodeMoved(BookmarkModel
* model
,
36 const BookmarkNode
* old_parent
,
38 const BookmarkNode
* new_parent
,
39 int new_index
) OVERRIDE
;
40 virtual void BookmarkNodeAdded(BookmarkModel
* model
,
41 const BookmarkNode
* parent
,
43 virtual void BookmarkNodeRemoved(BookmarkModel
* model
,
44 const BookmarkNode
* parent
,
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
;
56 DISALLOW_COPY_AND_ASSIGN(BookmarkModelObserverTask
);
59 #endif // CHROME_BROWSER_ANDROID_PROVIDER_BOOKMARK_MODEL_OBSERVER_TASK_H_