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

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

Issue 9317074: Create an API around UtilityProcessHost and use that from chrome. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 months 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) 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/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"
11 #include "chrome/browser/importer/firefox_importer_utils.h" 11 #include "chrome/browser/importer/firefox_importer_utils.h"
12 #include "chrome/browser/importer/importer_host.h" 12 #include "chrome/browser/importer/importer_host.h"
13 #include "chrome/browser/importer/in_process_importer_bridge.h" 13 #include "chrome/browser/importer/in_process_importer_bridge.h"
14 #include "chrome/browser/importer/profile_import_process_messages.h" 14 #include "chrome/browser/importer/profile_import_process_messages.h"
15 #include "chrome/browser/search_engines/template_url.h" 15 #include "chrome/browser/search_engines/template_url.h"
16 #include "chrome/browser/search_engines/template_url_service.h" 16 #include "chrome/browser/search_engines/template_url_service.h"
17 #include "content/browser/renderer_host/resource_dispatcher_host.h" 17 #include "content/browser/renderer_host/resource_dispatcher_host.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/utility_process_host.h"
19 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
20 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
21 22
22 using content::BrowserThread; 23 using content::BrowserThread;
24 using content::UtilityProcessHost;
23 25
24 ExternalProcessImporterClient::ExternalProcessImporterClient( 26 ExternalProcessImporterClient::ExternalProcessImporterClient(
25 ExternalProcessImporterHost* importer_host, 27 ExternalProcessImporterHost* importer_host,
26 const importer::SourceProfile& source_profile, 28 const importer::SourceProfile& source_profile,
27 uint16 items, 29 uint16 items,
28 InProcessImporterBridge* bridge) 30 InProcessImporterBridge* bridge)
29 : total_bookmarks_count_(0), 31 : total_bookmarks_count_(0),
30 total_history_rows_count_(0), 32 total_history_rows_count_(0),
31 total_favicons_count_(0), 33 total_favicons_count_(0),
32 process_importer_host_(importer_host), 34 process_importer_host_(importer_host),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 BrowserThread::PostTask( 70 BrowserThread::PostTask(
69 BrowserThread::IO, FROM_HERE, 71 BrowserThread::IO, FROM_HERE,
70 base::Bind(&ExternalProcessImporterClient::StartProcessOnIOThread, 72 base::Bind(&ExternalProcessImporterClient::StartProcessOnIOThread,
71 this, 73 this,
72 thread_id)); 74 thread_id));
73 } 75 }
74 76
75 void ExternalProcessImporterClient::StartProcessOnIOThread( 77 void ExternalProcessImporterClient::StartProcessOnIOThread(
76 BrowserThread::ID thread_id) { 78 BrowserThread::ID thread_id) {
77 utility_process_host_ = 79 utility_process_host_ =
78 (new UtilityProcessHost(this, thread_id))->AsWeakPtr(); 80 UtilityProcessHost::Create(this, thread_id)->AsWeakPtr();
79 utility_process_host_->set_no_sandbox(true); 81 utility_process_host_->DisableSandbox();
80 82
81 #if defined(OS_MACOSX) 83 #if defined(OS_MACOSX)
82 base::environment_vector env; 84 base::environment_vector env;
83 std::string dylib_path = GetFirefoxDylibPath().value(); 85 std::string dylib_path = GetFirefoxDylibPath().value();
84 if (!dylib_path.empty()) 86 if (!dylib_path.empty())
85 env.push_back(std::make_pair("DYLD_FALLBACK_LIBRARY_PATH", dylib_path)); 87 env.push_back(std::make_pair("DYLD_FALLBACK_LIBRARY_PATH", dylib_path));
86 utility_process_host_->set_env(env); 88 utility_process_host_->SetEnv(env);
87 #endif 89 #endif
88 90
89 // Dictionary of all localized strings that could be needed by the importer 91 // Dictionary of all localized strings that could be needed by the importer
90 // in the external process. 92 // in the external process.
91 DictionaryValue localized_strings; 93 DictionaryValue localized_strings;
92 localized_strings.SetString( 94 localized_strings.SetString(
93 base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), 95 base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX),
94 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)); 96 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX));
95 localized_strings.SetString( 97 localized_strings.SetString(
96 base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI), 98 base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI),
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 template_url_vec.reserve(template_urls.size()); 303 template_url_vec.reserve(template_urls.size());
302 std::vector<TemplateURL>::const_iterator iter; 304 std::vector<TemplateURL>::const_iterator iter;
303 for (iter = template_urls.begin(); 305 for (iter = template_urls.begin();
304 iter != template_urls.end(); 306 iter != template_urls.end();
305 ++iter) { 307 ++iter) {
306 template_url_vec.push_back(new TemplateURL(*iter)); 308 template_url_vec.push_back(new TemplateURL(*iter));
307 } 309 }
308 bridge_->SetKeywords(template_url_vec, default_keyword_index, 310 bridge_->SetKeywords(template_url_vec, default_keyword_index,
309 unique_on_host_and_path); 311 unique_on_host_and_path);
310 } 312 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/external_process_importer_client.h ('k') | chrome/browser/web_resource/web_resource_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698