| OLD | NEW |
| 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/profile_import/profile_import_thread.h" | 5 #include "chrome/profile_import/profile_import_thread.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/importer/importer.h" | 10 #include "chrome/browser/importer/importer.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 void ProfileImportThread::OnImportStart( | 42 void ProfileImportThread::OnImportStart( |
| 43 const ProfileInfo& profile_info, | 43 const ProfileInfo& profile_info, |
| 44 int items, | 44 int items, |
| 45 const DictionaryValue& localized_strings, | 45 const DictionaryValue& localized_strings, |
| 46 bool import_to_bookmark_bar) { | 46 bool import_to_bookmark_bar) { |
| 47 bridge_ = new ExternalProcessImporterBridge(this, localized_strings); | 47 bridge_ = new ExternalProcessImporterBridge(this, localized_strings); |
| 48 bridge_->AddRef(); // Balanced in Cleanup(). | 48 bridge_->AddRef(); // Balanced in Cleanup(). |
| 49 | 49 |
| 50 ImporterList importer_list; | 50 ImporterList importer_list; |
| 51 importer_ = importer_list.CreateImporterByType(profile_info.browser_type); | 51 importer_ = importer_list.CreateImporterByType(profile_info.browser_type); |
| 52 importer_->AddRef(); // Balanced in Cleanup(). | |
| 53 importer_->set_import_to_bookmark_bar(import_to_bookmark_bar); | |
| 54 items_to_import_ = items; | |
| 55 | |
| 56 if (!importer_) { | 52 if (!importer_) { |
| 57 Send(new ProfileImportProcessHostMsg_Import_Finished(false, | 53 Send(new ProfileImportProcessHostMsg_Import_Finished(false, |
| 58 "Importer could not be created.")); | 54 "Importer could not be created.")); |
| 59 return; | 55 return; |
| 60 } | 56 } |
| 61 | 57 |
| 58 importer_->AddRef(); // Balanced in Cleanup(). |
| 59 importer_->set_import_to_bookmark_bar(import_to_bookmark_bar); |
| 60 items_to_import_ = items; |
| 61 |
| 62 // Create worker thread in which importer runs. | 62 // Create worker thread in which importer runs. |
| 63 import_thread_.reset(new base::Thread("import_thread")); | 63 import_thread_.reset(new base::Thread("import_thread")); |
| 64 base::Thread::Options options; | 64 base::Thread::Options options; |
| 65 options.message_loop_type = MessageLoop::TYPE_IO; | 65 options.message_loop_type = MessageLoop::TYPE_IO; |
| 66 if (!import_thread_->StartWithOptions(options)) { | 66 if (!import_thread_->StartWithOptions(options)) { |
| 67 NOTREACHED(); | 67 NOTREACHED(); |
| 68 Cleanup(); | 68 Cleanup(); |
| 69 } | 69 } |
| 70 import_thread_->message_loop()->PostTask(FROM_HERE, | 70 import_thread_->message_loop()->PostTask(FROM_HERE, |
| 71 NewRunnableMethod(importer_, &Importer::StartImport, | 71 NewRunnableMethod(importer_, &Importer::StartImport, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 Send(new ProfileImportProcessHostMsg_NotifyKeywordsReady(urls, | 175 Send(new ProfileImportProcessHostMsg_NotifyKeywordsReady(urls, |
| 176 default_keyword_index, unique_on_host_and_path)); | 176 default_keyword_index, unique_on_host_and_path)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void ProfileImportThread::Cleanup() { | 179 void ProfileImportThread::Cleanup() { |
| 180 importer_->Cancel(); | 180 importer_->Cancel(); |
| 181 importer_->Release(); | 181 importer_->Release(); |
| 182 bridge_->Release(); | 182 bridge_->Release(); |
| 183 ChildProcess::current()->ReleaseProcess(); | 183 ChildProcess::current()->ReleaseProcess(); |
| 184 } | 184 } |
| OLD | NEW |