OLD | NEW |
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 CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ |
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
15 #include "base/task/cancelable_task_tracker.h" | 15 #include "base/task/cancelable_task_tracker.h" |
16 #include "components/favicon_base/favicon_types.h" | 16 #include "components/favicon_base/favicon_types.h" |
17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
19 | 19 |
20 class BookmarkNode; | 20 class BookmarkNode; |
21 class Profile; | 21 class Profile; |
22 | 22 |
23 namespace chrome { | 23 namespace chrome { |
24 struct FaviconBitmapResult; | 24 struct FaviconRawBitmapResult; |
25 } | 25 } |
26 | 26 |
27 // Observer for bookmark html output. Used only in tests. | 27 // Observer for bookmark html output. Used only in tests. |
28 class BookmarksExportObserver { | 28 class BookmarksExportObserver { |
29 public: | 29 public: |
30 // Is invoked on the IO thread. | 30 // Is invoked on the IO thread. |
31 virtual void OnExportFinished() = 0; | 31 virtual void OnExportFinished() = 0; |
32 | 32 |
33 protected: | 33 protected: |
34 virtual ~BookmarksExportObserver() {} | 34 virtual ~BookmarksExportObserver() {} |
(...skipping 29 matching lines...) Expand all Loading... |
64 void ExecuteWriter(); | 64 void ExecuteWriter(); |
65 | 65 |
66 // Starts async fetch for the next bookmark favicon. | 66 // Starts async fetch for the next bookmark favicon. |
67 // Takes single url from bookmark_urls_ and removes it from the list. | 67 // Takes single url from bookmark_urls_ and removes it from the list. |
68 // Returns true if there are more favicons to extract. | 68 // Returns true if there are more favicons to extract. |
69 bool FetchNextFavicon(); | 69 bool FetchNextFavicon(); |
70 | 70 |
71 // Favicon fetch callback. After all favicons are fetched executes | 71 // Favicon fetch callback. After all favicons are fetched executes |
72 // html output on the file thread. | 72 // html output on the file thread. |
73 void OnFaviconDataAvailable( | 73 void OnFaviconDataAvailable( |
74 const favicon_base::FaviconBitmapResult& bitmap_result); | 74 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
75 | 75 |
76 // The Profile object used for accessing FaviconService, bookmarks model. | 76 // The Profile object used for accessing FaviconService, bookmarks model. |
77 Profile* profile_; | 77 Profile* profile_; |
78 | 78 |
79 // All URLs that are extracted from bookmarks. Used to fetch favicons | 79 // All URLs that are extracted from bookmarks. Used to fetch favicons |
80 // for each of them. After favicon is fetched top url is removed from list. | 80 // for each of them. After favicon is fetched top url is removed from list. |
81 std::list<std::string> bookmark_urls_; | 81 std::list<std::string> bookmark_urls_; |
82 | 82 |
83 // Tracks favicon tasks. | 83 // Tracks favicon tasks. |
84 base::CancelableTaskTracker cancelable_task_tracker_; | 84 base::CancelableTaskTracker cancelable_task_tracker_; |
(...skipping 18 matching lines...) Expand all Loading... |
103 // thread is used. | 103 // thread is used. |
104 // Before writing to the file favicons are fetched on the main thread. | 104 // Before writing to the file favicons are fetched on the main thread. |
105 // TODO(sky): need a callback on failure. | 105 // TODO(sky): need a callback on failure. |
106 void WriteBookmarks(Profile* profile, | 106 void WriteBookmarks(Profile* profile, |
107 const base::FilePath& path, | 107 const base::FilePath& path, |
108 BookmarksExportObserver* observer); | 108 BookmarksExportObserver* observer); |
109 | 109 |
110 } // namespace bookmark_html_writer | 110 } // namespace bookmark_html_writer |
111 | 111 |
112 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ | 112 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ |
OLD | NEW |