| 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/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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 ~UnpackerClient() {} | 151 ~UnpackerClient() {} |
| 152 | 152 |
| 153 // UtilityProcessHost::Client | 153 // UtilityProcessHost::Client |
| 154 virtual bool OnMessageReceived(const IPC::Message& message) { | 154 virtual bool OnMessageReceived(const IPC::Message& message) { |
| 155 bool msg_is_ok = true; | 155 bool msg_is_ok = true; |
| 156 bool handled = true; | 156 bool handled = true; |
| 157 IPC_BEGIN_MESSAGE_MAP_EX(WebResourceService::UnpackerClient, message, | 157 IPC_BEGIN_MESSAGE_MAP_EX(WebResourceService::UnpackerClient, message, |
| 158 msg_is_ok) | 158 msg_is_ok) |
| 159 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Succeeded, | 159 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnpackWebResource_Succeeded, |
| 160 OnUnpackWebResourceSucceeded) | 160 OnUnpackWebResourceSucceeded) |
| 161 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Failed, | 161 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnpackWebResource_Failed, |
| 162 OnUnpackWebResourceFailed) | 162 OnUnpackWebResourceFailed) |
| 163 IPC_MESSAGE_UNHANDLED(handled = false) | 163 IPC_MESSAGE_UNHANDLED(handled = false) |
| 164 IPC_END_MESSAGE_MAP_EX() | 164 IPC_END_MESSAGE_MAP_EX() |
| 165 return handled; | 165 return handled; |
| 166 } | 166 } |
| 167 | 167 |
| 168 virtual void OnProcessCrashed(int exit_code) { | 168 virtual void OnProcessCrashed(int exit_code) { |
| 169 if (got_response_) | 169 if (got_response_) |
| 170 return; | 170 return; |
| 171 | 171 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 190 return; | 190 return; |
| 191 | 191 |
| 192 got_response_ = true; | 192 got_response_ = true; |
| 193 Release(); | 193 Release(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void StartProcessOnIOThread(BrowserThread::ID thread_id) { | 196 void StartProcessOnIOThread(BrowserThread::ID thread_id) { |
| 197 UtilityProcessHost* host = new UtilityProcessHost(this, thread_id); | 197 UtilityProcessHost* host = new UtilityProcessHost(this, thread_id); |
| 198 // TODO(mrc): get proper file path when we start using web resources | 198 // TODO(mrc): get proper file path when we start using web resources |
| 199 // that need to be unpacked. | 199 // that need to be unpacked. |
| 200 host->Send(new UtilityMsg_UnpackWebResource(json_data_)); | 200 host->Send(new ChromeUtilityMsg_UnpackWebResource(json_data_)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 scoped_refptr<WebResourceService> web_resource_service_; | 203 scoped_refptr<WebResourceService> web_resource_service_; |
| 204 | 204 |
| 205 // Holds raw JSON string. | 205 // Holds raw JSON string. |
| 206 const std::string& json_data_; | 206 const std::string& json_data_; |
| 207 | 207 |
| 208 // True if we got a response from the utility process and have cleaned up | 208 // True if we got a response from the utility process and have cleaned up |
| 209 // already. | 209 // already. |
| 210 bool got_response_; | 210 bool got_response_; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 294 } |
| 295 | 295 |
| 296 void WebResourceService::UpdateResourceCache(const std::string& json_data) { | 296 void WebResourceService::UpdateResourceCache(const std::string& json_data) { |
| 297 UnpackerClient* client = new UnpackerClient(this, json_data); | 297 UnpackerClient* client = new UnpackerClient(this, json_data); |
| 298 client->Start(); | 298 client->Start(); |
| 299 | 299 |
| 300 // Set cache update time in preferences. | 300 // Set cache update time in preferences. |
| 301 prefs_->SetString(last_update_time_pref_name_, | 301 prefs_->SetString(last_update_time_pref_name_, |
| 302 base::DoubleToString(base::Time::Now().ToDoubleT())); | 302 base::DoubleToString(base::Time::Now().ToDoubleT())); |
| 303 } | 303 } |
| OLD | NEW |