| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 103 } |
| 104 | 104 |
| 105 void Start() { | 105 void Start() { |
| 106 AddRef(); // balanced in Cleanup. | 106 AddRef(); // balanced in Cleanup. |
| 107 | 107 |
| 108 // If we don't have a resource_dispatcher_host_, assume we're in | 108 // If we don't have a resource_dispatcher_host_, assume we're in |
| 109 // a test and run the unpacker directly in-process. | 109 // a test and run the unpacker directly in-process. |
| 110 bool use_utility_process = | 110 bool use_utility_process = |
| 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 | |
| 114 #if defined(OS_LINUX) | |
| 115 // TODO(port): Don't use a utility process on linux (crbug.com/22703). | |
| 116 use_utility_process = false; | |
| 117 #endif | |
| 118 | |
| 119 if (use_utility_process) { | 113 if (use_utility_process) { |
| 120 ChromeThread::ID thread_id; | 114 ChromeThread::ID thread_id; |
| 121 CHECK(ChromeThread::GetCurrentThreadIdentifier(&thread_id)); | 115 CHECK(ChromeThread::GetCurrentThreadIdentifier(&thread_id)); |
| 122 ChromeThread::PostTask( | 116 ChromeThread::PostTask( |
| 123 ChromeThread::IO, FROM_HERE, | 117 ChromeThread::IO, FROM_HERE, |
| 124 NewRunnableMethod(this, &UnpackerClient::StartProcessOnIOThread, | 118 NewRunnableMethod(this, &UnpackerClient::StartProcessOnIOThread, |
| 125 web_resource_service_->resource_dispatcher_host_, | 119 web_resource_service_->resource_dispatcher_host_, |
| 126 thread_id)); | 120 thread_id)); |
| 127 } else { | 121 } else { |
| 128 WebResourceUnpacker unpacker(json_data_); | 122 WebResourceUnpacker unpacker(json_data_); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 288 |
| 295 void WebResourceService::UpdateResourceCache(const std::string& json_data) { | 289 void WebResourceService::UpdateResourceCache(const std::string& json_data) { |
| 296 UnpackerClient* client = new UnpackerClient(this, json_data); | 290 UnpackerClient* client = new UnpackerClient(this, json_data); |
| 297 client->Start(); | 291 client->Start(); |
| 298 | 292 |
| 299 // Update resource server and cache update time in preferences. | 293 // Update resource server and cache update time in preferences. |
| 300 prefs_->SetString(prefs::kNTPTipsCacheUpdate, | 294 prefs_->SetString(prefs::kNTPTipsCacheUpdate, |
| 301 DoubleToWString(base::Time::Now().ToDoubleT())); | 295 DoubleToWString(base::Time::Now().ToDoubleT())); |
| 302 prefs_->SetString(prefs::kNTPTipsServer, web_resource_server_); | 296 prefs_->SetString(prefs::kNTPTipsServer, web_resource_server_); |
| 303 } | 297 } |
| OLD | NEW |