| OLD | NEW |
| 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/utility/profile_import_handler.h" | 5 #include "chrome/utility/profile_import_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "chrome/common/importer/profile_import_process_messages.h" | 11 #include "chrome/common/importer/profile_import_process_messages.h" |
| 12 #include "chrome/utility/importer/external_process_importer_bridge.h" | 12 #include "chrome/utility/importer/external_process_importer_bridge.h" |
| 13 #include "chrome/utility/importer/importer.h" | 13 #include "chrome/utility/importer/importer.h" |
| 14 #include "chrome/utility/importer/importer_creator.h" | 14 #include "chrome/utility/importer/importer_creator.h" |
| 15 #include "content/public/utility/utility_thread.h" | 15 #include "content/public/utility/utility_thread.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 bool Send(IPC::Message* message) { | 19 bool Send(IPC::Message* message) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 38 return handled; | 38 return handled; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void ProfileImportHandler::OnImportStart( | 41 void ProfileImportHandler::OnImportStart( |
| 42 const importer::SourceProfile& source_profile, | 42 const importer::SourceProfile& source_profile, |
| 43 uint16 items, | 43 uint16 items, |
| 44 const base::DictionaryValue& localized_strings) { | 44 const base::DictionaryValue& localized_strings) { |
| 45 bridge_ = new ExternalProcessImporterBridge( | 45 bridge_ = new ExternalProcessImporterBridge( |
| 46 localized_strings, | 46 localized_strings, |
| 47 content::UtilityThread::Get(), | 47 content::UtilityThread::Get(), |
| 48 base::MessageLoopProxy::current().get()); | 48 base::ThreadTaskRunnerHandle::Get().get()); |
| 49 importer_ = importer::CreateImporterByType(source_profile.importer_type); | 49 importer_ = importer::CreateImporterByType(source_profile.importer_type); |
| 50 if (!importer_.get()) { | 50 if (!importer_.get()) { |
| 51 Send(new ProfileImportProcessHostMsg_Import_Finished( | 51 Send(new ProfileImportProcessHostMsg_Import_Finished( |
| 52 false, "Importer could not be created.")); | 52 false, "Importer could not be created.")); |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 | 55 |
| 56 items_to_import_ = items; | 56 items_to_import_ = items; |
| 57 | 57 |
| 58 // Create worker thread in which importer runs. | 58 // Create worker thread in which importer runs. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 void ProfileImportHandler::ImporterCleanup() { | 85 void ProfileImportHandler::ImporterCleanup() { |
| 86 importer_->Cancel(); | 86 importer_->Cancel(); |
| 87 importer_ = NULL; | 87 importer_ = NULL; |
| 88 bridge_ = NULL; | 88 bridge_ = NULL; |
| 89 import_thread_.reset(); | 89 import_thread_.reset(); |
| 90 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); | 90 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
| 91 } | 91 } |
| OLD | NEW |