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

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

Issue 10821097: Removing instances of profile_->GetBookmarkModel() as part of converting BookmarkModel to a PKS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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 "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"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/ref_counted_memory.h" 13 #include "base/memory/ref_counted_memory.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/platform_file.h" 16 #include "base/platform_file.h"
17 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
18 #include "base/time.h" 18 #include "base/time.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/bookmarks/bookmark_codec.h" 20 #include "chrome/browser/bookmarks/bookmark_codec.h"
21 #include "chrome/browser/bookmarks/bookmark_model.h" 21 #include "chrome/browser/bookmarks/bookmark_model.h"
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
22 #include "chrome/browser/history/history_types.h" 23 #include "chrome/browser/history/history_types.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
25 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/notification_source.h" 27 #include "content/public/browser/notification_source.h"
27 #include "grit/generated_resources.h" 28 #include "grit/generated_resources.h"
28 #include "net/base/escape.h" 29 #include "net/base/escape.h"
29 #include "net/base/file_stream.h" 30 #include "net/base/file_stream.h"
30 #include "net/base/net_errors.h" 31 #include "net/base/net_errors.h"
31 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 favicons_map_.reset(new URLFaviconMap()); 393 favicons_map_.reset(new URLFaviconMap());
393 registrar_.Add(this, 394 registrar_.Add(this,
394 chrome::NOTIFICATION_PROFILE_DESTROYED, 395 chrome::NOTIFICATION_PROFILE_DESTROYED,
395 content::Source<Profile>(profile_)); 396 content::Source<Profile>(profile_));
396 } 397 }
397 398
398 BookmarkFaviconFetcher::~BookmarkFaviconFetcher() { 399 BookmarkFaviconFetcher::~BookmarkFaviconFetcher() {
399 } 400 }
400 401
401 void BookmarkFaviconFetcher::ExportBookmarks() { 402 void BookmarkFaviconFetcher::ExportBookmarks() {
402 ExtractUrls(profile_->GetBookmarkModel()->bookmark_bar_node()); 403 ExtractUrls(BookmarkModelFactory::GetForProfile(
403 ExtractUrls(profile_->GetBookmarkModel()->other_node()); 404 profile_)->bookmark_bar_node());
404 ExtractUrls(profile_->GetBookmarkModel()->mobile_node()); 405 ExtractUrls(BookmarkModelFactory::GetForProfile(profile_)->other_node());
406 ExtractUrls(BookmarkModelFactory::GetForProfile(profile_)->mobile_node());
405 if (!bookmark_urls_.empty()) 407 if (!bookmark_urls_.empty())
406 FetchNextFavicon(); 408 FetchNextFavicon();
407 else 409 else
408 ExecuteWriter(); 410 ExecuteWriter();
409 } 411 }
410 412
411 void BookmarkFaviconFetcher::Observe( 413 void BookmarkFaviconFetcher::Observe(
412 int type, 414 int type,
413 const content::NotificationSource& source, 415 const content::NotificationSource& source,
414 const content::NotificationDetails& details) { 416 const content::NotificationDetails& details) {
(...skipping 15 matching lines...) Expand all
430 } 432 }
431 433
432 void BookmarkFaviconFetcher::ExecuteWriter() { 434 void BookmarkFaviconFetcher::ExecuteWriter() {
433 // BookmarkModel isn't thread safe (nor would we want to lock it down 435 // BookmarkModel isn't thread safe (nor would we want to lock it down
434 // for the duration of the write), as such we make a copy of the 436 // for the duration of the write), as such we make a copy of the
435 // BookmarkModel using BookmarkCodec then write from that. 437 // BookmarkModel using BookmarkCodec then write from that.
436 BookmarkCodec codec; 438 BookmarkCodec codec;
437 BrowserThread::PostTask( 439 BrowserThread::PostTask(
438 BrowserThread::FILE, FROM_HERE, 440 BrowserThread::FILE, FROM_HERE,
439 base::Bind(&Writer::DoWrite, 441 base::Bind(&Writer::DoWrite,
440 new Writer(codec.Encode(profile_->GetBookmarkModel()), 442 new Writer(codec.Encode(BookmarkModelFactory::GetForProfile(
443 profile_)),
441 path_, favicons_map_.release(), observer_))); 444 path_, favicons_map_.release(), observer_)));
442 if (fetcher != NULL) { 445 if (fetcher != NULL) {
443 MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher); 446 MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher);
444 fetcher = NULL; 447 fetcher = NULL;
445 } 448 }
446 } 449 }
447 450
448 bool BookmarkFaviconFetcher::FetchNextFavicon() { 451 bool BookmarkFaviconFetcher::FetchNextFavicon() {
449 if (bookmark_urls_.empty()) { 452 if (bookmark_urls_.empty()) {
450 return false; 453 return false;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // BookmarkModel isn't thread safe (nor would we want to lock it down 497 // BookmarkModel isn't thread safe (nor would we want to lock it down
495 // for the duration of the write), as such we make a copy of the 498 // for the duration of the write), as such we make a copy of the
496 // BookmarkModel using BookmarkCodec then write from that. 499 // BookmarkModel using BookmarkCodec then write from that.
497 if (fetcher == NULL) { 500 if (fetcher == NULL) {
498 fetcher = new BookmarkFaviconFetcher(profile, path, observer); 501 fetcher = new BookmarkFaviconFetcher(profile, path, observer);
499 fetcher->ExportBookmarks(); 502 fetcher->ExportBookmarks();
500 } 503 }
501 } 504 }
502 505
503 } // namespace bookmark_html_writer 506 } // namespace bookmark_html_writer
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_extension_api.cc ('k') | chrome/browser/bookmarks/bookmark_html_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698