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

Side by Side Diff: chrome/browser/importer/toolbar_importer.cc

Issue 345037: Fifth patch in getting rid of caching MessageLoop pointers. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 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/importer/toolbar_importer.h" 5 #include "chrome/browser/importer/toolbar_importer.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "chrome/browser/chrome_thread.h"
12 #include "chrome/browser/first_run.h" 13 #include "chrome/browser/first_run.h"
13 #include "chrome/browser/importer/importer_bridge.h" 14 #include "chrome/browser/importer/importer_bridge.h"
14 #include "chrome/browser/net/url_request_context_getter.h" 15 #include "chrome/browser/net/url_request_context_getter.h"
15 #include "chrome/common/libxml_utils.h" 16 #include "chrome/common/libxml_utils.h"
16 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
17 #include "net/base/cookie_monster.h" 18 #include "net/base/cookie_monster.h"
18 #include "net/base/data_url.h" 19 #include "net/base/data_url.h"
19 #include "net/url_request/url_request_context.h" 20 #include "net/url_request/url_request_context.h"
20 21
21 // 22 //
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // as well as an internal callback in case of cancel. An internal callback 107 // as well as an internal callback in case of cancel. An internal callback
107 // is required since the URLFetcher must be destroyed from the thread it was 108 // is required since the URLFetcher must be destroyed from the thread it was
108 // created. 109 // created.
109 void Toolbar5Importer::Cancel() { 110 void Toolbar5Importer::Cancel() {
110 // In the case when the thread is not importing messages we are to 111 // In the case when the thread is not importing messages we are to
111 // cancel as soon as possible. 112 // cancel as soon as possible.
112 Importer::Cancel(); 113 Importer::Cancel();
113 114
114 // If we are conducting network operations, post a message to the importer 115 // If we are conducting network operations, post a message to the importer
115 // thread for synchronization. 116 // thread for synchronization.
116 if (NULL != bridge_->delegate_loop_) { 117 if (ChromeThread::CurrentlyOn(ChromeThread::UI)) {
117 if (bridge_->delegate_loop_ != MessageLoop::current()) { 118 EndImport();
118 bridge_->delegate_loop_->PostTask( 119 } else {
119 FROM_HERE, 120 ChromeThread::PostTask(
120 NewRunnableMethod(this, &Toolbar5Importer::Cancel)); 121 ChromeThread::UI, FROM_HERE,
121 } else { 122 NewRunnableMethod(this, &Toolbar5Importer::Cancel));
122 EndImport();
123 }
124 } 123 }
125 } 124 }
126 125
127 void Toolbar5Importer::OnURLFetchComplete( 126 void Toolbar5Importer::OnURLFetchComplete(
128 const URLFetcher* source, 127 const URLFetcher* source,
129 const GURL& url, 128 const GURL& url,
130 const URLRequestStatus& status, 129 const URLRequestStatus& status,
131 int response_code, 130 int response_code,
132 const ResponseCookies& cookies, 131 const ResponseCookies& cookies,
133 const std::string& data) { 132 const std::string& data) {
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 void Toolbar5Importer::AddBookmarksToChrome( 577 void Toolbar5Importer::AddBookmarksToChrome(
579 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) { 578 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) {
580 if (!bookmarks.empty() && !cancelled()) { 579 if (!bookmarks.empty() && !cancelled()) {
581 const std::wstring& first_folder_name = 580 const std::wstring& first_folder_name =
582 l10n_util::GetString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR); 581 l10n_util::GetString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR);
583 int options = ProfileWriter::ADD_IF_UNIQUE | 582 int options = ProfileWriter::ADD_IF_UNIQUE |
584 (import_to_bookmark_bar() ? ProfileWriter::IMPORT_TO_BOOKMARK_BAR : 0); 583 (import_to_bookmark_bar() ? ProfileWriter::IMPORT_TO_BOOKMARK_BAR : 0);
585 bridge_->AddBookmarkEntries(bookmarks, first_folder_name, options); 584 bridge_->AddBookmarkEntries(bookmarks, first_folder_name, options);
586 } 585 }
587 } 586 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698