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

Side by Side Diff: chrome/browser/dom_ui/options/import_data_handler.cc

Issue 4146004: ThreadRestrictions: disallow blocking IO on the UI thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/dom_ui/options/import_data_handler.h" 5 #include "chrome/browser/dom_ui/options/import_data_handler.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h"
9 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
10 #include "base/string16.h" 11 #include "base/string16.h"
11 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
12 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/thread_restrictions.h"
13 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 16 #include "base/values.h"
15 #include "base/callback.h"
16 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/profile.h" 18 #include "chrome/browser/profile.h"
18 #include "grit/chromium_strings.h" 19 #include "grit/chromium_strings.h"
19 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
20 #include "chrome/browser/importer/importer_data_types.h" 21 #include "chrome/browser/importer/importer_data_types.h"
21 22
22 ImportDataHandler::ImportDataHandler() : importer_host_(NULL) { 23 ImportDataHandler::ImportDataHandler() : importer_host_(NULL) {
23 } 24 }
24 25
25 ImportDataHandler::~ImportDataHandler() { 26 ImportDataHandler::~ImportDataHandler() {
(...skipping 19 matching lines...) Expand all
45 localized_strings->SetString("import_passwords", 46 localized_strings->SetString("import_passwords",
46 l10n_util::GetStringUTF16(IDS_IMPORT_PASSWORDS_CHKBOX)); 47 l10n_util::GetStringUTF16(IDS_IMPORT_PASSWORDS_CHKBOX));
47 localized_strings->SetString("import_history", 48 localized_strings->SetString("import_history",
48 l10n_util::GetStringUTF16(IDS_IMPORT_HISTORY_CHKBOX)); 49 l10n_util::GetStringUTF16(IDS_IMPORT_HISTORY_CHKBOX));
49 localized_strings->SetString("no_profile_found", 50 localized_strings->SetString("no_profile_found",
50 l10n_util::GetStringUTF16(IDS_IMPORT_NO_PROFILE_FOUND)); 51 l10n_util::GetStringUTF16(IDS_IMPORT_NO_PROFILE_FOUND));
51 } 52 }
52 53
53 void ImportDataHandler::Initialize() { 54 void ImportDataHandler::Initialize() {
54 importer_list_.reset(new ImporterList); 55 importer_list_.reset(new ImporterList);
56
57 // We should not be loading profiles from the UI thread!
58 // Temporarily allow this until we fix
59 // http://code.google.com/p/chromium/issues/detail?id=60825
60 base::ThreadRestrictions::ScopedAllowIO allow_io;
55 importer_list_->DetectSourceProfiles(); 61 importer_list_->DetectSourceProfiles();
56 int profiles_count = importer_list_->GetAvailableProfileCount(); 62 int profiles_count = importer_list_->GetAvailableProfileCount();
57 63
58 ListValue browser_profiles; 64 ListValue browser_profiles;
59 if (profiles_count > 0) { 65 if (profiles_count > 0) {
60 for (int i = 0; i < profiles_count; i++) { 66 for (int i = 0; i < profiles_count; i++) {
61 const importer::ProfileInfo& source_profile = 67 const importer::ProfileInfo& source_profile =
62 importer_list_->GetSourceProfileInfoAt(i); 68 importer_list_->GetSourceProfileInfoAt(i);
63 string16 browser_name = WideToUTF16Hack(source_profile.description); 69 string16 browser_name = WideToUTF16Hack(source_profile.description);
64 uint16 browser_services = source_profile.services_supported; 70 uint16 browser_services = source_profile.services_supported;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void ImportDataHandler::ImportItemEnded(importer::ImportItem item) { 159 void ImportDataHandler::ImportItemEnded(importer::ImportItem item) {
154 // TODO(csilv): show progress detail in the web view. 160 // TODO(csilv): show progress detail in the web view.
155 } 161 }
156 162
157 void ImportDataHandler::ImportEnded() { 163 void ImportDataHandler::ImportEnded() {
158 importer_host_->SetObserver(NULL); 164 importer_host_->SetObserver(NULL);
159 importer_host_ = NULL; 165 importer_host_ = NULL;
160 166
161 dom_ui_->CallJavascriptFunction(L"ImportDataOverlay.dismiss"); 167 dom_ui_->CallJavascriptFunction(L"ImportDataOverlay.dismiss");
162 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698