Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/browser/loader/resource_message_filter.h

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_MESSAGE_FILTER_H_ 5 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_MESSAGE_FILTER_H_
6 #define CONTENT_BROWSER_LOADER_RESOURCE_MESSAGE_FILTER_H_ 6 #define CONTENT_BROWSER_LOADER_RESOURCE_MESSAGE_FILTER_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "content/public/browser/browser_message_filter.h" 12 #include "content/public/browser/browser_message_filter.h"
13 #include "content/public/common/resource_type.h" 13 #include "content/public/common/resource_type.h"
14 14
15 struct ResourceHostMsg_Request; 15 struct ResourceHostMsg_Request;
16 16
17 namespace fileapi { 17 namespace storage {
18 class FileSystemContext; 18 class FileSystemContext;
19 } // namespace fileapi 19 } // namespace storage
20 20
21 namespace net { 21 namespace net {
22 class URLRequestContext; 22 class URLRequestContext;
23 } // namespace net 23 } // namespace net
24 24
25 25
26 namespace content { 26 namespace content {
27 class ChromeAppCacheService; 27 class ChromeAppCacheService;
28 class ChromeBlobStorageContext; 28 class ChromeBlobStorageContext;
29 class ResourceContext; 29 class ResourceContext;
30 class ServiceWorkerContextWrapper; 30 class ServiceWorkerContextWrapper;
31 31
32 // This class filters out incoming IPC messages for network requests and 32 // This class filters out incoming IPC messages for network requests and
33 // processes them on the IPC thread. As a result, network requests are not 33 // processes them on the IPC thread. As a result, network requests are not
34 // delayed by costly UI processing that may be occuring on the main thread of 34 // delayed by costly UI processing that may be occuring on the main thread of
35 // the browser. It also means that any hangs in starting a network request 35 // the browser. It also means that any hangs in starting a network request
36 // will not interfere with browser UI. 36 // will not interfere with browser UI.
37 class CONTENT_EXPORT ResourceMessageFilter : public BrowserMessageFilter { 37 class CONTENT_EXPORT ResourceMessageFilter : public BrowserMessageFilter {
38 public: 38 public:
39 typedef base::Callback<void(const ResourceHostMsg_Request&, 39 typedef base::Callback<void(const ResourceHostMsg_Request&,
40 ResourceContext**, 40 ResourceContext**,
41 net::URLRequestContext**)> GetContextsCallback; 41 net::URLRequestContext**)> GetContextsCallback;
42 42
43 // |appcache_service|, |blob_storage_context|, |file_system_context| may be 43 // |appcache_service|, |blob_storage_context|, |file_system_context| may be
44 // NULL in unittests or for requests from the (NPAPI) plugin process. 44 // NULL in unittests or for requests from the (NPAPI) plugin process.
45 ResourceMessageFilter( 45 ResourceMessageFilter(int child_id,
46 int child_id, 46 int process_type,
47 int process_type, 47 ChromeAppCacheService* appcache_service,
48 ChromeAppCacheService* appcache_service, 48 ChromeBlobStorageContext* blob_storage_context,
49 ChromeBlobStorageContext* blob_storage_context, 49 storage::FileSystemContext* file_system_context,
50 fileapi::FileSystemContext* file_system_context, 50 ServiceWorkerContextWrapper* service_worker_context,
51 ServiceWorkerContextWrapper* service_worker_context, 51 const GetContextsCallback& get_contexts_callback);
52 const GetContextsCallback& get_contexts_callback);
53 52
54 // BrowserMessageFilter implementation. 53 // BrowserMessageFilter implementation.
55 virtual void OnChannelClosing() OVERRIDE; 54 virtual void OnChannelClosing() OVERRIDE;
56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 55 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
57 56
58 void GetContexts(const ResourceHostMsg_Request& request, 57 void GetContexts(const ResourceHostMsg_Request& request,
59 ResourceContext** resource_context, 58 ResourceContext** resource_context,
60 net::URLRequestContext** request_context); 59 net::URLRequestContext** request_context);
61 60
62 // Returns the net::URLRequestContext for the given request. 61 // Returns the net::URLRequestContext for the given request.
63 net::URLRequestContext* GetURLRequestContext(ResourceType request_type); 62 net::URLRequestContext* GetURLRequestContext(ResourceType request_type);
64 63
65 ChromeAppCacheService* appcache_service() const { 64 ChromeAppCacheService* appcache_service() const {
66 return appcache_service_.get(); 65 return appcache_service_.get();
67 } 66 }
68 67
69 ChromeBlobStorageContext* blob_storage_context() const { 68 ChromeBlobStorageContext* blob_storage_context() const {
70 return blob_storage_context_.get(); 69 return blob_storage_context_.get();
71 } 70 }
72 71
73 fileapi::FileSystemContext* file_system_context() const { 72 storage::FileSystemContext* file_system_context() const {
74 return file_system_context_.get(); 73 return file_system_context_.get();
75 } 74 }
76 75
77 ServiceWorkerContextWrapper* service_worker_context() const { 76 ServiceWorkerContextWrapper* service_worker_context() const {
78 return service_worker_context_.get(); 77 return service_worker_context_.get();
79 } 78 }
80 79
81 int child_id() const { return child_id_; } 80 int child_id() const { return child_id_; }
82 int process_type() const { return process_type_; } 81 int process_type() const { return process_type_; }
83 82
84 base::WeakPtr<ResourceMessageFilter> GetWeakPtr(); 83 base::WeakPtr<ResourceMessageFilter> GetWeakPtr();
85 84
86 protected: 85 protected:
87 // Protected destructor so that we can be overriden in tests. 86 // Protected destructor so that we can be overriden in tests.
88 virtual ~ResourceMessageFilter(); 87 virtual ~ResourceMessageFilter();
89 88
90 private: 89 private:
91 // The ID of the child process. 90 // The ID of the child process.
92 int child_id_; 91 int child_id_;
93 92
94 int process_type_; 93 int process_type_;
95 94
96 scoped_refptr<ChromeAppCacheService> appcache_service_; 95 scoped_refptr<ChromeAppCacheService> appcache_service_;
97 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; 96 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
98 scoped_refptr<fileapi::FileSystemContext> file_system_context_; 97 scoped_refptr<storage::FileSystemContext> file_system_context_;
99 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; 98 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
100 99
101 GetContextsCallback get_contexts_callback_; 100 GetContextsCallback get_contexts_callback_;
102 101
103 // This must come last to make sure weak pointers are invalidated first. 102 // This must come last to make sure weak pointers are invalidated first.
104 base::WeakPtrFactory<ResourceMessageFilter> weak_ptr_factory_; 103 base::WeakPtrFactory<ResourceMessageFilter> weak_ptr_factory_;
105 104
106 DISALLOW_IMPLICIT_CONSTRUCTORS(ResourceMessageFilter); 105 DISALLOW_IMPLICIT_CONSTRUCTORS(ResourceMessageFilter);
107 }; 106 };
108 107
109 } // namespace content 108 } // namespace content
110 109
111 #endif // CONTENT_BROWSER_LOADER_RESOURCE_MESSAGE_FILTER_H_ 110 #endif // CONTENT_BROWSER_LOADER_RESOURCE_MESSAGE_FILTER_H_
OLDNEW
« no previous file with comments | « content/browser/loader/resource_loader_unittest.cc ('k') | content/browser/loader/resource_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698