| OLD | NEW |
| 1 // Copyright (c) 2009 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/appcache/appcache_dispatcher_host.h" | 5 #include "chrome/browser/appcache/appcache_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "chrome/browser/appcache/chrome_appcache_service.h" | 8 #include "chrome/browser/appcache/chrome_appcache_service.h" |
| 9 #include "chrome/browser/metrics/user_metrics.h" | 9 #include "chrome/browser/metrics/user_metrics.h" |
| 10 #include "chrome/browser/net/chrome_url_request_context.h" | 10 #include "chrome/browser/net/chrome_url_request_context.h" |
| 11 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 11 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
| 13 | 13 |
| 14 AppCacheDispatcherHost::AppCacheDispatcherHost( | 14 AppCacheDispatcherHost::AppCacheDispatcherHost( |
| 15 URLRequestContext* request_context, | 15 net::URLRequestContext* request_context, |
| 16 int process_id) | 16 int process_id) |
| 17 : ALLOW_THIS_IN_INITIALIZER_LIST(frontend_proxy_(this)), | 17 : ALLOW_THIS_IN_INITIALIZER_LIST(frontend_proxy_(this)), |
| 18 request_context_(request_context), | 18 request_context_(request_context), |
| 19 process_id_(process_id) { | 19 process_id_(process_id) { |
| 20 DCHECK(request_context_.get()); | 20 DCHECK(request_context_.get()); |
| 21 } | 21 } |
| 22 | 22 |
| 23 AppCacheDispatcherHost::AppCacheDispatcherHost( | 23 AppCacheDispatcherHost::AppCacheDispatcherHost( |
| 24 URLRequestContextGetter* request_context_getter, | 24 URLRequestContextGetter* request_context_getter, |
| 25 int process_id) | 25 int process_id) |
| 26 : ALLOW_THIS_IN_INITIALIZER_LIST(frontend_proxy_(this)), | 26 : ALLOW_THIS_IN_INITIALIZER_LIST(frontend_proxy_(this)), |
| 27 request_context_getter_(request_context_getter), | 27 request_context_getter_(request_context_getter), |
| 28 process_id_(process_id) { | 28 process_id_(process_id) { |
| 29 DCHECK(request_context_getter_.get()); | 29 DCHECK(request_context_getter_.get()); |
| 30 } | 30 } |
| 31 | 31 |
| 32 AppCacheDispatcherHost::~AppCacheDispatcherHost() {} | 32 AppCacheDispatcherHost::~AppCacheDispatcherHost() {} |
| 33 | 33 |
| 34 void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) { | 34 void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) { |
| 35 BrowserMessageFilter::OnChannelConnected(peer_pid); | 35 BrowserMessageFilter::OnChannelConnected(peer_pid); |
| 36 | 36 |
| 37 DCHECK(request_context_.get() || request_context_getter_.get()); | 37 DCHECK(request_context_.get() || request_context_getter_.get()); |
| 38 | 38 |
| 39 // Get the AppCacheService (it can only be accessed from IO thread). | 39 // Get the AppCacheService (it can only be accessed from IO thread). |
| 40 URLRequestContext* context = request_context_.get(); | 40 net::URLRequestContext* context = request_context_.get(); |
| 41 if (!context) | 41 if (!context) |
| 42 context = request_context_getter_->GetURLRequestContext(); | 42 context = request_context_getter_->GetURLRequestContext(); |
| 43 appcache_service_ = | 43 appcache_service_ = |
| 44 static_cast<ChromeURLRequestContext*>(context)->appcache_service(); | 44 static_cast<ChromeURLRequestContext*>(context)->appcache_service(); |
| 45 request_context_ = NULL; | 45 request_context_ = NULL; |
| 46 request_context_getter_ = NULL; | 46 request_context_getter_ = NULL; |
| 47 | 47 |
| 48 if (appcache_service_.get()) { | 48 if (appcache_service_.get()) { |
| 49 backend_impl_.Initialize( | 49 backend_impl_.Initialize( |
| 50 appcache_service_.get(), &frontend_proxy_, process_id_); | 50 appcache_service_.get(), &frontend_proxy_, process_id_); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 AppCacheMsg_StartUpdate::WriteReplyParams(reply_msg, result); | 228 AppCacheMsg_StartUpdate::WriteReplyParams(reply_msg, result); |
| 229 Send(pending_reply_msg_.release()); | 229 Send(pending_reply_msg_.release()); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { | 232 void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { |
| 233 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); | 233 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); |
| 234 DCHECK(reply_msg == pending_reply_msg_.get()); | 234 DCHECK(reply_msg == pending_reply_msg_.get()); |
| 235 AppCacheMsg_SwapCache::WriteReplyParams(reply_msg, result); | 235 AppCacheMsg_SwapCache::WriteReplyParams(reply_msg, result); |
| 236 Send(pending_reply_msg_.release()); | 236 Send(pending_reply_msg_.release()); |
| 237 } | 237 } |
| OLD | NEW |