OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/external_process_importer_client.h" | 5 #include "chrome/browser/importer/external_process_importer_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/importer/external_process_importer_host.h" | 10 #include "chrome/browser/importer/external_process_importer_host.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 ExternalProcessImporterClient::ExternalProcessImporterClient( | 24 ExternalProcessImporterClient::ExternalProcessImporterClient( |
25 ExternalProcessImporterHost* importer_host, | 25 ExternalProcessImporterHost* importer_host, |
26 const importer::SourceProfile& source_profile, | 26 const importer::SourceProfile& source_profile, |
27 uint16 items, | 27 uint16 items, |
28 InProcessImporterBridge* bridge) | 28 InProcessImporterBridge* bridge) |
29 : total_bookmarks_count_(0), | 29 : total_bookmarks_count_(0), |
30 total_history_rows_count_(0), | 30 total_history_rows_count_(0), |
31 total_favicons_count_(0), | 31 total_favicons_count_(0), |
32 process_importer_host_(importer_host), | 32 process_importer_host_(importer_host), |
33 utility_process_host_(NULL), | |
34 source_profile_(source_profile), | 33 source_profile_(source_profile), |
35 items_(items), | 34 items_(items), |
36 bridge_(bridge), | 35 bridge_(bridge), |
37 cancelled_(false) { | 36 cancelled_(false) { |
38 bridge_->AddRef(); | 37 bridge_->AddRef(); |
39 process_importer_host_->NotifyImportStarted(); | 38 process_importer_host_->NotifyImportStarted(); |
40 } | 39 } |
41 | 40 |
42 ExternalProcessImporterClient::~ExternalProcessImporterClient() { | 41 ExternalProcessImporterClient::~ExternalProcessImporterClient() { |
43 bridge_->Release(); | 42 bridge_->Release(); |
(...skipping 24 matching lines...) Expand all Loading... |
68 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id)); | 67 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id)); |
69 BrowserThread::PostTask( | 68 BrowserThread::PostTask( |
70 BrowserThread::IO, FROM_HERE, | 69 BrowserThread::IO, FROM_HERE, |
71 base::Bind(&ExternalProcessImporterClient::StartProcessOnIOThread, | 70 base::Bind(&ExternalProcessImporterClient::StartProcessOnIOThread, |
72 this, | 71 this, |
73 thread_id)); | 72 thread_id)); |
74 } | 73 } |
75 | 74 |
76 void ExternalProcessImporterClient::StartProcessOnIOThread( | 75 void ExternalProcessImporterClient::StartProcessOnIOThread( |
77 BrowserThread::ID thread_id) { | 76 BrowserThread::ID thread_id) { |
78 utility_process_host_ = new UtilityProcessHost(this, thread_id); | 77 utility_process_host_ = |
| 78 (new UtilityProcessHost(this, thread_id))->AsWeakPtr(); |
79 utility_process_host_->set_no_sandbox(true); | 79 utility_process_host_->set_no_sandbox(true); |
80 | 80 |
81 #if defined(OS_MACOSX) | 81 #if defined(OS_MACOSX) |
82 base::environment_vector env; | 82 base::environment_vector env; |
83 std::string dylib_path = GetFirefoxDylibPath().value(); | 83 std::string dylib_path = GetFirefoxDylibPath().value(); |
84 if (!dylib_path.empty()) | 84 if (!dylib_path.empty()) |
85 env.push_back(std::make_pair("DYLD_FALLBACK_LIBRARY_PATH", dylib_path)); | 85 env.push_back(std::make_pair("DYLD_FALLBACK_LIBRARY_PATH", dylib_path)); |
86 utility_process_host_->set_env(env); | 86 utility_process_host_->set_env(env); |
87 #endif | 87 #endif |
88 | 88 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 BrowserThread::PostTask( | 121 BrowserThread::PostTask( |
122 BrowserThread::IO, FROM_HERE, | 122 BrowserThread::IO, FROM_HERE, |
123 base::Bind( | 123 base::Bind( |
124 &ExternalProcessImporterClient::CancelImportProcessOnIOThread, | 124 &ExternalProcessImporterClient::CancelImportProcessOnIOThread, |
125 this)); | 125 this)); |
126 } | 126 } |
127 Release(); | 127 Release(); |
128 } | 128 } |
129 | 129 |
130 void ExternalProcessImporterClient::OnProcessCrashed(int exit_code) { | 130 void ExternalProcessImporterClient::OnProcessCrashed(int exit_code) { |
131 utility_process_host_ = NULL; | |
132 if (cancelled_) | 131 if (cancelled_) |
133 return; | 132 return; |
134 | 133 |
135 process_importer_host_->Cancel(); | 134 process_importer_host_->Cancel(); |
136 } | 135 } |
137 | 136 |
138 bool ExternalProcessImporterClient::OnMessageReceived( | 137 bool ExternalProcessImporterClient::OnMessageReceived( |
139 const IPC::Message& message) { | 138 const IPC::Message& message) { |
140 bool handled = true; | 139 bool handled = true; |
141 IPC_BEGIN_MESSAGE_MAP(ExternalProcessImporterClient, message) | 140 IPC_BEGIN_MESSAGE_MAP(ExternalProcessImporterClient, message) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 template_url_vec.reserve(template_urls.size()); | 301 template_url_vec.reserve(template_urls.size()); |
303 std::vector<TemplateURL>::const_iterator iter; | 302 std::vector<TemplateURL>::const_iterator iter; |
304 for (iter = template_urls.begin(); | 303 for (iter = template_urls.begin(); |
305 iter != template_urls.end(); | 304 iter != template_urls.end(); |
306 ++iter) { | 305 ++iter) { |
307 template_url_vec.push_back(new TemplateURL(*iter)); | 306 template_url_vec.push_back(new TemplateURL(*iter)); |
308 } | 307 } |
309 bridge_->SetKeywords(template_url_vec, default_keyword_index, | 308 bridge_->SetKeywords(template_url_vec, default_keyword_index, |
310 unique_on_host_and_path); | 309 unique_on_host_and_path); |
311 } | 310 } |
OLD | NEW |