Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chrome/browser/bookmarks/bookmark_html_writer.cc

Issue 2033753002: Remove use of deprecated MessageLoop methods in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual change Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/location.h"
17 #include "base/macros.h" 18 #include "base/macros.h"
18 #include "base/message_loop/message_loop.h" 19 #include "base/single_thread_task_runner.h"
19 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/threading/thread_task_runner_handle.h"
21 #include "base/time/time.h" 23 #include "base/time/time.h"
22 #include "base/values.h" 24 #include "base/values.h"
23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
24 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
25 #include "chrome/browser/favicon/favicon_service_factory.h" 27 #include "chrome/browser/favicon/favicon_service_factory.h"
26 #include "components/bookmarks/browser/bookmark_codec.h" 28 #include "components/bookmarks/browser/bookmark_codec.h"
27 #include "components/bookmarks/browser/bookmark_model.h" 29 #include "components/bookmarks/browser/bookmark_model.h"
28 #include "components/favicon/core/favicon_service.h" 30 #include "components/favicon/core/favicon_service.h"
29 #include "components/favicon_base/favicon_types.h" 31 #include "components/favicon_base/favicon_types.h"
30 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 FetchNextFavicon(); 417 FetchNextFavicon();
416 else 418 else
417 ExecuteWriter(); 419 ExecuteWriter();
418 } 420 }
419 421
420 void BookmarkFaviconFetcher::Observe( 422 void BookmarkFaviconFetcher::Observe(
421 int type, 423 int type,
422 const content::NotificationSource& source, 424 const content::NotificationSource& source,
423 const content::NotificationDetails& details) { 425 const content::NotificationDetails& details) {
424 if (chrome::NOTIFICATION_PROFILE_DESTROYED == type && fetcher != NULL) { 426 if (chrome::NOTIFICATION_PROFILE_DESTROYED == type && fetcher != NULL) {
425 base::MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher); 427 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, fetcher);
426 fetcher = NULL; 428 fetcher = NULL;
427 } 429 }
428 } 430 }
429 431
430 void BookmarkFaviconFetcher::ExtractUrls(const BookmarkNode* node) { 432 void BookmarkFaviconFetcher::ExtractUrls(const BookmarkNode* node) {
431 if (node->is_url()) { 433 if (node->is_url()) {
432 std::string url = node->url().spec(); 434 std::string url = node->url().spec();
433 if (!url.empty()) 435 if (!url.empty())
434 bookmark_urls_.push_back(url); 436 bookmark_urls_.push_back(url);
435 } else { 437 } else {
436 for (int i = 0; i < node->child_count(); ++i) 438 for (int i = 0; i < node->child_count(); ++i)
437 ExtractUrls(node->GetChild(i)); 439 ExtractUrls(node->GetChild(i));
438 } 440 }
439 } 441 }
440 442
441 void BookmarkFaviconFetcher::ExecuteWriter() { 443 void BookmarkFaviconFetcher::ExecuteWriter() {
442 // BookmarkModel isn't thread safe (nor would we want to lock it down 444 // BookmarkModel isn't thread safe (nor would we want to lock it down
443 // for the duration of the write), as such we make a copy of the 445 // for the duration of the write), as such we make a copy of the
444 // BookmarkModel using BookmarkCodec then write from that. 446 // BookmarkModel using BookmarkCodec then write from that.
445 BookmarkCodec codec; 447 BookmarkCodec codec;
446 BrowserThread::PostTask( 448 BrowserThread::PostTask(
447 BrowserThread::FILE, FROM_HERE, 449 BrowserThread::FILE, FROM_HERE,
448 base::Bind(&Writer::DoWrite, 450 base::Bind(&Writer::DoWrite,
449 new Writer(codec.Encode(BookmarkModelFactory::GetForProfile( 451 new Writer(codec.Encode(BookmarkModelFactory::GetForProfile(
450 profile_)), 452 profile_)),
451 path_, favicons_map_.release(), observer_))); 453 path_, favicons_map_.release(), observer_)));
452 if (fetcher != NULL) { 454 if (fetcher != NULL) {
453 base::MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher); 455 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, fetcher);
454 fetcher = NULL; 456 fetcher = NULL;
455 } 457 }
456 } 458 }
457 459
458 bool BookmarkFaviconFetcher::FetchNextFavicon() { 460 bool BookmarkFaviconFetcher::FetchNextFavicon() {
459 if (bookmark_urls_.empty()) { 461 if (bookmark_urls_.empty()) {
460 return false; 462 return false;
461 } 463 }
462 do { 464 do {
463 std::string url = bookmark_urls_.front(); 465 std::string url = bookmark_urls_.front();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 // BookmarkModel isn't thread safe (nor would we want to lock it down 510 // BookmarkModel isn't thread safe (nor would we want to lock it down
509 // for the duration of the write), as such we make a copy of the 511 // for the duration of the write), as such we make a copy of the
510 // BookmarkModel using BookmarkCodec then write from that. 512 // BookmarkModel using BookmarkCodec then write from that.
511 if (fetcher == NULL) { 513 if (fetcher == NULL) {
512 fetcher = new BookmarkFaviconFetcher(profile, path, observer); 514 fetcher = new BookmarkFaviconFetcher(profile, path, observer);
513 fetcher->ExportBookmarks(); 515 fetcher->ExportBookmarks();
514 } 516 }
515 } 517 }
516 518
517 } // namespace bookmark_html_writer 519 } // namespace bookmark_html_writer
OLDNEW
« no previous file with comments | « chrome/browser/background/background_contents_service.cc ('k') | chrome/browser/browser_process_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698