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 "content/browser/appcache/appcache_dispatcher_host.h" | 5 #include "content/browser/appcache/appcache_dispatcher_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "content/browser/appcache/chrome_appcache_service.h" | 9 #include "content/browser/appcache/chrome_appcache_service.h" |
10 #include "content/common/appcache_messages.h" | 10 #include "content/common/appcache_messages.h" |
11 #include "content/public/browser/user_metrics.h" | 11 #include "content/public/browser/user_metrics.h" |
12 | 12 |
13 using content::BrowserMessageFilter; | 13 using content::BrowserMessageFilter; |
14 using content::UserMetricsAction; | 14 using content::UserMetricsAction; |
15 | 15 |
16 AppCacheDispatcherHost::AppCacheDispatcherHost( | 16 AppCacheDispatcherHost::AppCacheDispatcherHost( |
17 ChromeAppCacheService* appcache_service, | 17 ChromeAppCacheService* appcache_service, |
18 int process_id) | 18 int process_id) |
19 : appcache_service_(appcache_service), | 19 : appcache_service_(appcache_service), |
20 ALLOW_THIS_IN_INITIALIZER_LIST(frontend_proxy_(this)), | 20 ALLOW_THIS_IN_INITIALIZER_LIST(frontend_proxy_(this)), |
21 process_id_(process_id) { | 21 process_id_(process_id) { |
22 } | 22 } |
23 | 23 |
24 AppCacheDispatcherHost::~AppCacheDispatcherHost() {} | |
25 | |
26 void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) { | 24 void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) { |
27 BrowserMessageFilter::OnChannelConnected(peer_pid); | 25 BrowserMessageFilter::OnChannelConnected(peer_pid); |
28 if (appcache_service_.get()) { | 26 if (appcache_service_.get()) { |
29 backend_impl_.Initialize( | 27 backend_impl_.Initialize( |
30 appcache_service_.get(), &frontend_proxy_, process_id_); | 28 appcache_service_.get(), &frontend_proxy_, process_id_); |
31 get_status_callback_ = | 29 get_status_callback_ = |
32 base::Bind(&AppCacheDispatcherHost::GetStatusCallback, | 30 base::Bind(&AppCacheDispatcherHost::GetStatusCallback, |
33 base::Unretained(this)); | 31 base::Unretained(this)); |
34 start_update_callback_ = | 32 start_update_callback_ = |
35 base::Bind(&AppCacheDispatcherHost::StartUpdateCallback, | 33 base::Bind(&AppCacheDispatcherHost::StartUpdateCallback, |
(...skipping 21 matching lines...) Expand all Loading... |
57 OnMarkAsForeignEntry) | 55 OnMarkAsForeignEntry) |
58 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheHostMsg_GetStatus, OnGetStatus) | 56 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheHostMsg_GetStatus, OnGetStatus) |
59 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheHostMsg_StartUpdate, OnStartUpdate) | 57 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheHostMsg_StartUpdate, OnStartUpdate) |
60 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheHostMsg_SwapCache, OnSwapCache) | 58 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheHostMsg_SwapCache, OnSwapCache) |
61 IPC_MESSAGE_UNHANDLED(handled = false) | 59 IPC_MESSAGE_UNHANDLED(handled = false) |
62 IPC_END_MESSAGE_MAP_EX() | 60 IPC_END_MESSAGE_MAP_EX() |
63 | 61 |
64 return handled; | 62 return handled; |
65 } | 63 } |
66 | 64 |
| 65 AppCacheDispatcherHost::~AppCacheDispatcherHost() {} |
| 66 |
67 void AppCacheDispatcherHost::BadMessageReceived() { | 67 void AppCacheDispatcherHost::BadMessageReceived() { |
68 content::RecordAction(UserMetricsAction("BadMessageTerminate_ACDH")); | 68 content::RecordAction(UserMetricsAction("BadMessageTerminate_ACDH")); |
69 BrowserMessageFilter::BadMessageReceived(); | 69 BrowserMessageFilter::BadMessageReceived(); |
70 } | 70 } |
71 | 71 |
72 void AppCacheDispatcherHost::OnRegisterHost(int host_id) { | 72 void AppCacheDispatcherHost::OnRegisterHost(int host_id) { |
73 if (appcache_service_.get()) { | 73 if (appcache_service_.get()) { |
74 if (!backend_impl_.RegisterHost(host_id)) { | 74 if (!backend_impl_.RegisterHost(host_id)) { |
75 BadMessageReceived(); | 75 BadMessageReceived(); |
76 } | 76 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 AppCacheHostMsg_StartUpdate::WriteReplyParams(reply_msg, result); | 219 AppCacheHostMsg_StartUpdate::WriteReplyParams(reply_msg, result); |
220 Send(pending_reply_msg_.release()); | 220 Send(pending_reply_msg_.release()); |
221 } | 221 } |
222 | 222 |
223 void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { | 223 void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { |
224 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); | 224 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); |
225 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); | 225 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); |
226 AppCacheHostMsg_SwapCache::WriteReplyParams(reply_msg, result); | 226 AppCacheHostMsg_SwapCache::WriteReplyParams(reply_msg, result); |
227 Send(pending_reply_msg_.release()); | 227 Send(pending_reply_msg_.release()); |
228 } | 228 } |
OLD | NEW |