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

Side by Side Diff: chrome/browser/web_resource/web_resource_service.cc

Issue 6805008: Remove RDH from UtilityProcessHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oops, can only use g_browser_process on the UI thread. Created 9 years, 8 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) 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/web_resource/web_resource_service.h" 5 #include "chrome/browser/web_resource/web_resource_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 : web_resource_service_(web_resource_service), 119 : web_resource_service_(web_resource_service),
120 json_data_(json_data), got_response_(false) { 120 json_data_(json_data), got_response_(false) {
121 } 121 }
122 122
123 void Start() { 123 void Start() {
124 AddRef(); // balanced in Cleanup. 124 AddRef(); // balanced in Cleanup.
125 125
126 // If we don't have a resource_dispatcher_host_, assume we're in 126 // If we don't have a resource_dispatcher_host_, assume we're in
127 // a test and run the unpacker directly in-process. 127 // a test and run the unpacker directly in-process.
128 bool use_utility_process = 128 bool use_utility_process =
129 web_resource_service_->resource_dispatcher_host_ != NULL && 129 web_resource_service_->resource_dispatcher_host_ != NULL &&
jam 2011/04/06 16:28:36 looks like we don't need resource_dispatcher_host_
willchan no longer on Chromium 2011/04/06 16:37:25 I was too lazy to do that. I'm happy to do it thou
jam 2011/04/06 16:52:30 hmm, good question :) I guess we can still check
willchan no longer on Chromium 2011/04/06 16:59:12 I ran into an issue earlier where the extension co
130 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); 130 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
131 if (use_utility_process) { 131 if (use_utility_process) {
132 BrowserThread::ID thread_id; 132 BrowserThread::ID thread_id;
133 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id)); 133 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id));
134 BrowserThread::PostTask( 134 BrowserThread::PostTask(
135 BrowserThread::IO, FROM_HERE, 135 BrowserThread::IO, FROM_HERE,
136 NewRunnableMethod(this, &UnpackerClient::StartProcessOnIOThread, 136 NewRunnableMethod(this, &UnpackerClient::StartProcessOnIOThread,
137 web_resource_service_->resource_dispatcher_host_,
138 thread_id)); 137 thread_id));
139 } else { 138 } else {
140 WebResourceUnpacker unpacker(json_data_); 139 WebResourceUnpacker unpacker(json_data_);
141 if (unpacker.Run()) { 140 if (unpacker.Run()) {
142 OnUnpackWebResourceSucceeded(*unpacker.parsed_json()); 141 OnUnpackWebResourceSucceeded(*unpacker.parsed_json());
143 } else { 142 } else {
144 OnUnpackWebResourceFailed(unpacker.error_message()); 143 OnUnpackWebResourceFailed(unpacker.error_message());
145 } 144 }
146 } 145 }
147 } 146 }
(...skipping 23 matching lines...) Expand all
171 170
172 // Release reference and set got_response_. 171 // Release reference and set got_response_.
173 void Cleanup() { 172 void Cleanup() {
174 if (got_response_) 173 if (got_response_)
175 return; 174 return;
176 175
177 got_response_ = true; 176 got_response_ = true;
178 Release(); 177 Release();
179 } 178 }
180 179
181 void StartProcessOnIOThread(ResourceDispatcherHost* rdh, 180 void StartProcessOnIOThread(BrowserThread::ID thread_id) {
182 BrowserThread::ID thread_id) { 181 UtilityProcessHost* host = new UtilityProcessHost(this, thread_id);
183 UtilityProcessHost* host = new UtilityProcessHost(rdh, this, thread_id);
184 // TODO(mrc): get proper file path when we start using web resources 182 // TODO(mrc): get proper file path when we start using web resources
185 // that need to be unpacked. 183 // that need to be unpacked.
186 host->StartWebResourceUnpacker(json_data_); 184 host->StartWebResourceUnpacker(json_data_);
187 } 185 }
188 186
189 scoped_refptr<WebResourceService> web_resource_service_; 187 scoped_refptr<WebResourceService> web_resource_service_;
190 188
191 // Holds raw JSON string. 189 // Holds raw JSON string.
192 const std::string& json_data_; 190 const std::string& json_data_;
193 191
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 279 }
282 280
283 void WebResourceService::UpdateResourceCache(const std::string& json_data) { 281 void WebResourceService::UpdateResourceCache(const std::string& json_data) {
284 UnpackerClient* client = new UnpackerClient(this, json_data); 282 UnpackerClient* client = new UnpackerClient(this, json_data);
285 client->Start(); 283 client->Start();
286 284
287 // Set cache update time in preferences. 285 // Set cache update time in preferences.
288 prefs_->SetString(last_update_time_pref_name_, 286 prefs_->SetString(last_update_time_pref_name_,
289 base::DoubleToString(base::Time::Now().ToDoubleT())); 287 base::DoubleToString(base::Time::Now().ToDoubleT()));
290 } 288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698