| OLD | NEW |
| 1 // Copyright (c) 2011 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 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 5 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Class responsible for the actual writing. Takes ownership of favicons_map. | 86 // Class responsible for the actual writing. Takes ownership of favicons_map. |
| 87 class Writer : public base::RefCountedThreadSafe<Writer> { | 87 class Writer : public base::RefCountedThreadSafe<Writer> { |
| 88 public: | 88 public: |
| 89 Writer(base::Value* bookmarks, | 89 Writer(base::Value* bookmarks, |
| 90 const FilePath& path, | 90 const FilePath& path, |
| 91 BookmarkFaviconFetcher::URLFaviconMap* favicons_map, | 91 BookmarkFaviconFetcher::URLFaviconMap* favicons_map, |
| 92 BookmarksExportObserver* observer) | 92 BookmarksExportObserver* observer) |
| 93 : bookmarks_(bookmarks), | 93 : bookmarks_(bookmarks), |
| 94 path_(path), | 94 path_(path), |
| 95 favicons_map_(favicons_map), | 95 favicons_map_(favicons_map), |
| 96 observer_(observer) { | 96 observer_(observer), |
| 97 file_stream_(NULL) { |
| 97 } | 98 } |
| 98 | 99 |
| 99 // Writing bookmarks and favicons data to file. | 100 // Writing bookmarks and favicons data to file. |
| 100 void DoWrite() { | 101 void DoWrite() { |
| 101 if (!OpenFile()) | 102 if (!OpenFile()) |
| 102 return; | 103 return; |
| 103 | 104 |
| 104 Value* roots; | 105 Value* roots; |
| 105 if (!Write(kHeader) || | 106 if (!Write(kHeader) || |
| 106 bookmarks_->GetType() != Value::TYPE_DICTIONARY || | 107 bookmarks_->GetType() != Value::TYPE_DICTIONARY || |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 // BookmarkModel isn't thread safe (nor would we want to lock it down | 490 // BookmarkModel isn't thread safe (nor would we want to lock it down |
| 490 // for the duration of the write), as such we make a copy of the | 491 // for the duration of the write), as such we make a copy of the |
| 491 // BookmarkModel using BookmarkCodec then write from that. | 492 // BookmarkModel using BookmarkCodec then write from that. |
| 492 if (fetcher == NULL) { | 493 if (fetcher == NULL) { |
| 493 fetcher = new BookmarkFaviconFetcher(profile, path, observer); | 494 fetcher = new BookmarkFaviconFetcher(profile, path, observer); |
| 494 fetcher->ExportBookmarks(); | 495 fetcher->ExportBookmarks(); |
| 495 } | 496 } |
| 496 } | 497 } |
| 497 | 498 |
| 498 } // namespace bookmark_html_writer | 499 } // namespace bookmark_html_writer |
| OLD | NEW |