OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/web_resource/web_resource_service.h" | 4 #include "chrome/browser/web_resource/web_resource_service.h" |
5 | 5 |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 web_resource_service_->resource_dispatcher_host_ != NULL && | 111 web_resource_service_->resource_dispatcher_host_ != NULL && |
112 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); | 112 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); |
113 | 113 |
114 #if defined(OS_POSIX) | 114 #if defined(OS_POSIX) |
115 // TODO(port): Don't use a utility process on linux (crbug.com/22703) or | 115 // TODO(port): Don't use a utility process on linux (crbug.com/22703) or |
116 // MacOS (crbug.com/8102) until problems related to autoupdate are fixed. | 116 // MacOS (crbug.com/8102) until problems related to autoupdate are fixed. |
117 use_utility_process = false; | 117 use_utility_process = false; |
118 #endif | 118 #endif |
119 | 119 |
120 if (use_utility_process) { | 120 if (use_utility_process) { |
| 121 ChromeThread::ID thread_id; |
| 122 CHECK(ChromeThread::GetCurrentThreadIdentifier(&thread_id)); |
121 ChromeThread::PostTask( | 123 ChromeThread::PostTask( |
122 ChromeThread::IO, FROM_HERE, | 124 ChromeThread::IO, FROM_HERE, |
123 NewRunnableMethod(this, &UnpackerClient::StartProcessOnIOThread, | 125 NewRunnableMethod(this, &UnpackerClient::StartProcessOnIOThread, |
124 web_resource_service_->resource_dispatcher_host_, | 126 web_resource_service_->resource_dispatcher_host_, |
125 MessageLoop::current())); | 127 thread_id)); |
126 } else { | 128 } else { |
127 WebResourceUnpacker unpacker(json_data_); | 129 WebResourceUnpacker unpacker(json_data_); |
128 if (unpacker.Run()) { | 130 if (unpacker.Run()) { |
129 OnUnpackWebResourceSucceeded(*unpacker.parsed_json()); | 131 OnUnpackWebResourceSucceeded(*unpacker.parsed_json()); |
130 } else { | 132 } else { |
131 OnUnpackWebResourceFailed(unpacker.error_message()); | 133 OnUnpackWebResourceFailed(unpacker.error_message()); |
132 } | 134 } |
133 } | 135 } |
134 } | 136 } |
135 | 137 |
(...skipping 21 matching lines...) Expand all Loading... |
157 // Release reference and set got_response_. | 159 // Release reference and set got_response_. |
158 void Cleanup() { | 160 void Cleanup() { |
159 if (got_response_) | 161 if (got_response_) |
160 return; | 162 return; |
161 | 163 |
162 got_response_ = true; | 164 got_response_ = true; |
163 Release(); | 165 Release(); |
164 } | 166 } |
165 | 167 |
166 void StartProcessOnIOThread(ResourceDispatcherHost* rdh, | 168 void StartProcessOnIOThread(ResourceDispatcherHost* rdh, |
167 MessageLoop* file_loop) { | 169 ChromeThread::ID thread_id) { |
168 UtilityProcessHost* host = new UtilityProcessHost(rdh, this, file_loop); | 170 UtilityProcessHost* host = new UtilityProcessHost(rdh, this, thread_id); |
169 // TODO(mrc): get proper file path when we start using web resources | 171 // TODO(mrc): get proper file path when we start using web resources |
170 // that need to be unpacked. | 172 // that need to be unpacked. |
171 host->StartWebResourceUnpacker(json_data_); | 173 host->StartWebResourceUnpacker(json_data_); |
172 } | 174 } |
173 | 175 |
174 scoped_refptr<WebResourceService> web_resource_service_; | 176 scoped_refptr<WebResourceService> web_resource_service_; |
175 | 177 |
176 // Holds raw JSON string. | 178 // Holds raw JSON string. |
177 const std::string& json_data_; | 179 const std::string& json_data_; |
178 | 180 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // languages, which can be different from the locale. | 310 // languages, which can be different from the locale. |
309 std::wstring languageList = prefs->GetString(prefs::kAcceptLanguages); | 311 std::wstring languageList = prefs->GetString(prefs::kAcceptLanguages); |
310 int pos = languageList.find(L","); | 312 int pos = languageList.find(L","); |
311 pos = pos >= 0 ? pos : languageList.length(); | 313 pos = pos >= 0 ? pos : languageList.length(); |
312 return languageList.substr(0, pos); | 314 return languageList.substr(0, pos); |
313 #else | 315 #else |
314 return ASCIIToWide(g_browser_process->GetApplicationLocale()); | 316 return ASCIIToWide(g_browser_process->GetApplicationLocale()); |
315 #endif | 317 #endif |
316 } | 318 } |
317 | 319 |
OLD | NEW |