1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "content/browser/loader/resource_message_filter.h" 6 7 #include "content/browser/appcache/chrome_appcache_service.h" 8 #include "content/browser/fileapi/chrome_blob_storage_context.h" 9 #include "content/browser/loader/resource_dispatcher_host_impl.h" 10 #include "content/public/browser/resource_context.h" 11 #include "webkit/browser/fileapi/file_system_context.h" 12 13 namespace content { 14 15 ResourceMessageFilter::ResourceMessageFilter( 16 int child_id, 17 int process_type, 18 ResourceContext* resource_context, 19 ChromeAppCacheService* appcache_service, 20 ChromeBlobStorageContext* blob_storage_context, 21 fileapi::FileSystemContext* file_system_context, 22 URLRequestContextSelector* url_request_context_selector) 23 : child_id_(child_id), 24 process_type_(process_type), 25 resource_context_(resource_context), 26 appcache_service_(appcache_service), 27 blob_storage_context_(blob_storage_context), 28 file_system_context_(file_system_context), 29 url_request_context_selector_(url_request_context_selector) { 30 DCHECK(resource_context); 31 DCHECK(url_request_context_selector); 32 // |appcache_service| and |blob_storage_context| may be NULL in unittests. 33 } 34 35 ResourceMessageFilter::~ResourceMessageFilter() { 36 } 37 38 void ResourceMessageFilter::OnChannelClosing() { 39 BrowserMessageFilter::OnChannelClosing(); 40 41 // Unhook us from all pending network requests so they don't get sent to a 42 // deleted object. 43 ResourceDispatcherHostImpl::Get()->CancelRequestsForProcess(child_id_); 44 } 45 46 bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message, 47 bool* message_was_ok) { 48 return ResourceDispatcherHostImpl::Get()->OnMessageReceived( 49 message, this, message_was_ok); 50 } 51 52 net::URLRequestContext* ResourceMessageFilter::GetURLRequestContext( 53 ResourceType::Type type) { 54 return url_request_context_selector_->GetRequestContext(type); 55 } 56 57 } // namespace content 58