summaryrefslogtreecommitdiffstats
path: root/chrome/browser/appcache
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-28 23:37:20 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-28 23:37:20 +0000
commitf22a79585707eef6ef87672e8b89845122108052 (patch)
treeef450ea8694fc29af73f6738f4253f99db783e20 /chrome/browser/appcache
parent353a34ce51417f032198c1c537af4180d8eb9af2 (diff)
downloadchromium_src-f22a79585707eef6ef87672e8b89845122108052.zip
chromium_src-f22a79585707eef6ef87672e8b89845122108052.tar.gz
chromium_src-f22a79585707eef6ef87672e8b89845122108052.tar.bz2
Defend against messages being received prior to having been initialized.
BUG=none TEST=none Review URL: http://codereview.chromium.org/2321002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48542 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/appcache')
-rw-r--r--chrome/browser/appcache/appcache_dispatcher_host.cc21
-rw-r--r--chrome/browser/appcache/appcache_dispatcher_host.h11
2 files changed, 16 insertions, 16 deletions
diff --git a/chrome/browser/appcache/appcache_dispatcher_host.cc b/chrome/browser/appcache/appcache_dispatcher_host.cc
index 2edb22f..b3a7bb0 100644
--- a/chrome/browser/appcache/appcache_dispatcher_host.cc
+++ b/chrome/browser/appcache/appcache_dispatcher_host.cc
@@ -13,24 +13,23 @@
AppCacheDispatcherHost::AppCacheDispatcherHost(
URLRequestContext* request_context)
: request_context_(request_context),
- process_handle_(0) {
+ receiver_(NULL) {
DCHECK(request_context_.get());
}
AppCacheDispatcherHost::AppCacheDispatcherHost(
URLRequestContextGetter* request_context_getter)
: request_context_getter_(request_context_getter),
- process_handle_(0) {
+ receiver_(NULL) {
DCHECK(request_context_getter_.get());
}
-void AppCacheDispatcherHost::Initialize(IPC::Message::Sender* sender,
- int process_id, base::ProcessHandle process_handle) {
- DCHECK(sender);
- DCHECK(process_handle && !process_handle_);
+void AppCacheDispatcherHost::Initialize(
+ ResourceDispatcherHost::Receiver* receiver) {
+ DCHECK(receiver && !receiver_);
DCHECK(request_context_.get() || request_context_getter_.get());
- process_handle_ = process_handle;
+ receiver_ = receiver;
// Get the AppCacheService (it can only be accessed from IO thread).
URLRequestContext* context = request_context_.get();
@@ -41,10 +40,10 @@ void AppCacheDispatcherHost::Initialize(IPC::Message::Sender* sender,
request_context_ = NULL;
request_context_getter_ = NULL;
- frontend_proxy_.set_sender(sender);
+ frontend_proxy_.set_sender(receiver);
if (appcache_service_.get()) {
backend_impl_.Initialize(
- appcache_service_.get(), &frontend_proxy_, process_id);
+ appcache_service_.get(), &frontend_proxy_, receiver->id());
get_status_callback_.reset(
NewCallback(this, &AppCacheDispatcherHost::GetStatusCallback));
start_update_callback_.reset(
@@ -56,7 +55,7 @@ void AppCacheDispatcherHost::Initialize(IPC::Message::Sender* sender,
bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg,
bool *msg_ok) {
- DCHECK(process_handle_);
+ DCHECK(receiver_);
*msg_ok = true;
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, msg, *msg_ok)
@@ -229,5 +228,5 @@ void AppCacheDispatcherHost::ReceivedBadMessage(uint32 msg_type) {
// TODO(michaeln): Consider gathering UMA stats
// http://code.google.com/p/chromium/issues/detail?id=24634
BrowserRenderProcessHost::BadMessageTerminateProcess(
- msg_type, process_handle_);
+ msg_type, receiver_->handle());
}
diff --git a/chrome/browser/appcache/appcache_dispatcher_host.h b/chrome/browser/appcache/appcache_dispatcher_host.h
index 887a9af..37ff02e 100644
--- a/chrome/browser/appcache/appcache_dispatcher_host.h
+++ b/chrome/browser/appcache/appcache_dispatcher_host.h
@@ -11,6 +11,7 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/appcache/appcache_frontend_proxy.h"
+#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "ipc/ipc_message.h"
#include "webkit/appcache/appcache_backend_impl.h"
@@ -20,8 +21,8 @@ class URLRequestContextGetter;
// Handles appcache related messages sent to the main browser process from
// its child processes. There is a distinct host for each child process.
-// Messages are handled on the IO thread. The ResourceMessageFilter creates
-// an instance and delegates calls to it.
+// Messages are handled on the IO thread. The ResourceMessageFilter and
+// WorkerProcessHost create an instance and delegates calls to it.
class AppCacheDispatcherHost {
public:
// Constructor for use on the IO thread.
@@ -32,8 +33,7 @@ class AppCacheDispatcherHost {
explicit AppCacheDispatcherHost(
URLRequestContextGetter* request_context_getter);
- void Initialize(IPC::Message::Sender* sender, int process_id,
- base::ProcessHandle process_handle);
+ void Initialize(ResourceDispatcherHost::Receiver* receiver);
bool OnMessageReceived(const IPC::Message& msg, bool* msg_is_ok);
int process_id() const { return backend_impl_.process_id(); }
@@ -79,9 +79,10 @@ class AppCacheDispatcherHost {
scoped_ptr<appcache::GetStatusCallback> get_status_callback_;
scoped_ptr<appcache::StartUpdateCallback> start_update_callback_;
scoped_ptr<appcache::SwapCacheCallback> swap_cache_callback_;
- base::ProcessHandle process_handle_;
scoped_ptr<IPC::Message> pending_reply_msg_;
+ ResourceDispatcherHost::Receiver* receiver_;
+
DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost);
};