Chromium Code Reviews| 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 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 5 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/base64.h" | 12 #include "base/base64.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/files/file.h" | 16 #include "base/files/file.h" |
| 17 #include "base/lazy_instance.h" | |
|
gab
2017/07/20 19:11:14
unused
Sébastien Marchand
2017/07/21 15:45:25
Done.
| |
| 17 #include "base/location.h" | 18 #include "base/location.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 23 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 24 #include "base/values.h" | 25 #include "base/values.h" |
| 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 26 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 26 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 for (int i = 0; i < node->child_count(); ++i) | 442 for (int i = 0; i < node->child_count(); ++i) |
| 442 ExtractUrls(node->GetChild(i)); | 443 ExtractUrls(node->GetChild(i)); |
| 443 } | 444 } |
| 444 } | 445 } |
| 445 | 446 |
| 446 void BookmarkFaviconFetcher::ExecuteWriter() { | 447 void BookmarkFaviconFetcher::ExecuteWriter() { |
| 447 // BookmarkModel isn't thread safe (nor would we want to lock it down | 448 // BookmarkModel isn't thread safe (nor would we want to lock it down |
| 448 // for the duration of the write), as such we make a copy of the | 449 // for the duration of the write), as such we make a copy of the |
| 449 // BookmarkModel using BookmarkCodec then write from that. | 450 // BookmarkModel using BookmarkCodec then write from that. |
| 450 BookmarkCodec codec; | 451 BookmarkCodec codec; |
| 451 BrowserThread::PostTask( | 452 |
| 452 BrowserThread::FILE, FROM_HERE, | 453 background_io_task_runner_->PostTask( |
| 454 FROM_HERE, | |
| 453 base::BindOnce( | 455 base::BindOnce( |
| 454 &Writer::DoWrite, | 456 &Writer::DoWrite, |
| 455 new Writer(codec.Encode( | 457 new Writer(codec.Encode( |
| 456 BookmarkModelFactory::GetForBrowserContext(profile_)), | 458 BookmarkModelFactory::GetForBrowserContext(profile_)), |
| 457 path_, favicons_map_.release(), observer_))); | 459 path_, favicons_map_.release(), observer_))); |
| 458 if (g_fetcher) { | 460 if (g_fetcher) { |
| 459 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, g_fetcher); | 461 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, g_fetcher); |
| 460 g_fetcher = nullptr; | 462 g_fetcher = nullptr; |
| 461 } | 463 } |
| 462 } | 464 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 // BookmarkModel isn't thread safe (nor would we want to lock it down | 516 // BookmarkModel isn't thread safe (nor would we want to lock it down |
| 515 // for the duration of the write), as such we make a copy of the | 517 // for the duration of the write), as such we make a copy of the |
| 516 // BookmarkModel using BookmarkCodec then write from that. | 518 // BookmarkModel using BookmarkCodec then write from that. |
| 517 if (!g_fetcher) { | 519 if (!g_fetcher) { |
| 518 g_fetcher = new BookmarkFaviconFetcher(profile, path, observer); | 520 g_fetcher = new BookmarkFaviconFetcher(profile, path, observer); |
| 519 g_fetcher->ExportBookmarks(); | 521 g_fetcher->ExportBookmarks(); |
| 520 } | 522 } |
| 521 } | 523 } |
| 522 | 524 |
| 523 } // namespace bookmark_html_writer | 525 } // namespace bookmark_html_writer |
| OLD | NEW |