| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_codec.h" | 15 #include "chrome/browser/bookmarks/bookmark_codec.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_model.h" | 16 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 17 #include "chrome/browser/chrome_thread.h" |
| 17 #include "chrome/browser/history/history_types.h" | 18 #include "chrome/browser/history/history_types.h" |
| 18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 19 #include "net/base/escape.h" | 20 #include "net/base/escape.h" |
| 20 #include "net/base/file_stream.h" | 21 #include "net/base/file_stream.h" |
| 21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 22 | 23 |
| 23 namespace bookmark_html_writer { | 24 namespace bookmark_html_writer { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // File we're writing to. | 310 // File we're writing to. |
| 310 net::FileStream file_stream_; | 311 net::FileStream file_stream_; |
| 311 | 312 |
| 312 // How much we indent when writing a bookmark/folder. This is modified | 313 // How much we indent when writing a bookmark/folder. This is modified |
| 313 // via IncrementIndent and DecrementIndent. | 314 // via IncrementIndent and DecrementIndent. |
| 314 std::string indent_; | 315 std::string indent_; |
| 315 }; | 316 }; |
| 316 | 317 |
| 317 } // namespace | 318 } // namespace |
| 318 | 319 |
| 319 void WriteBookmarks(MessageLoop* thread, | 320 void WriteBookmarks(BookmarkModel* model, const FilePath& path) { |
| 320 BookmarkModel* model, | |
| 321 const FilePath& path) { | |
| 322 // BookmarkModel isn't thread safe (nor would we want to lock it down | 321 // BookmarkModel isn't thread safe (nor would we want to lock it down |
| 323 // for the duration of the write), as such we make a copy of the | 322 // for the duration of the write), as such we make a copy of the |
| 324 // BookmarkModel using BookmarkCodec then write from that. | 323 // BookmarkModel using BookmarkCodec then write from that. |
| 325 BookmarkCodec codec; | 324 BookmarkCodec codec; |
| 326 scoped_ptr<Writer> writer(new Writer(codec.Encode(model), path)); | 325 ChromeThread::PostTask( |
| 327 if (thread) | 326 ChromeThread::FILE, FROM_HERE, new Writer(codec.Encode(model), path)); |
| 328 thread->PostTask(FROM_HERE, writer.release()); | |
| 329 else | |
| 330 writer->Run(); | |
| 331 } | 327 } |
| 332 | 328 |
| 333 } // namespace bookmark_html_writer | 329 } // namespace bookmark_html_writer |
| OLD | NEW |