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

Side by Side Diff: content/browser/service_worker/service_worker_request_handler.h

Issue 293083002: Add a blob field to ServiceWorkerFetchResponse and read the blob (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix merge conflict Created 6 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/supports_user_data.h" 10 #include "base/supports_user_data.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "content/common/service_worker/service_worker_status_code.h" 12 #include "content/common/service_worker/service_worker_status_code.h"
13 #include "net/url_request/url_request_job_factory.h" 13 #include "net/url_request/url_request_job_factory.h"
14 #include "webkit/common/resource_type.h" 14 #include "webkit/common/resource_type.h"
15 15
16 namespace net { 16 namespace net {
17 class NetworkDelegate; 17 class NetworkDelegate;
18 class URLRequest; 18 class URLRequest;
19 } 19 }
20 20
21 namespace webkit_blob {
22 class BlobStorageContext;
23 }
24
21 namespace content { 25 namespace content {
22 26
23 class ServiceWorkerContextCore; 27 class ServiceWorkerContextCore;
24 class ServiceWorkerContextWrapper; 28 class ServiceWorkerContextWrapper;
25 class ServiceWorkerProviderHost; 29 class ServiceWorkerProviderHost;
26 30
27 // Abstract base class for routing network requests to ServiceWorkers. 31 // Abstract base class for routing network requests to ServiceWorkers.
28 // Created one per URLRequest and attached to each request. 32 // Created one per URLRequest and attached to each request.
29 class CONTENT_EXPORT ServiceWorkerRequestHandler 33 class CONTENT_EXPORT ServiceWorkerRequestHandler
30 : public base::SupportsUserData::Data { 34 : public base::SupportsUserData::Data {
31 public: 35 public:
32 // Attaches a newly created handler if the given |request| needs to 36 // Attaches a newly created handler if the given |request| needs to
33 // be handled by ServiceWorker. 37 // be handled by ServiceWorker.
34 // TODO(kinuko): While utilizing UserData to attach data to URLRequest 38 // TODO(kinuko): While utilizing UserData to attach data to URLRequest
35 // has some precedence, it might be better to attach this handler in a more 39 // has some precedence, it might be better to attach this handler in a more
36 // explicit way within content layer, e.g. have ResourceRequestInfoImpl 40 // explicit way within content layer, e.g. have ResourceRequestInfoImpl
37 // own it. 41 // own it.
38 static void InitializeHandler( 42 static void InitializeHandler(
39 net::URLRequest* request, 43 net::URLRequest* request,
40 ServiceWorkerContextWrapper* context_wrapper, 44 ServiceWorkerContextWrapper* context_wrapper,
45 webkit_blob::BlobStorageContext* blob_storage_context,
41 int process_id, 46 int process_id,
42 int provider_id, 47 int provider_id,
43 ResourceType::Type resource_type); 48 ResourceType::Type resource_type);
44 49
45 // Returns the handler attached to |request|. This may return NULL 50 // Returns the handler attached to |request|. This may return NULL
46 // if no handler is attached. 51 // if no handler is attached.
47 static ServiceWorkerRequestHandler* GetHandler( 52 static ServiceWorkerRequestHandler* GetHandler(
48 net::URLRequest* request); 53 net::URLRequest* request);
49 54
50 // Creates a protocol interceptor for ServiceWorker. 55 // Creates a protocol interceptor for ServiceWorker.
51 static scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 56 static scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
52 CreateInterceptor(); 57 CreateInterceptor();
53 58
54 virtual ~ServiceWorkerRequestHandler(); 59 virtual ~ServiceWorkerRequestHandler();
55 60
56 // Called via custom URLRequestJobFactory. 61 // Called via custom URLRequestJobFactory.
57 virtual net::URLRequestJob* MaybeCreateJob( 62 virtual net::URLRequestJob* MaybeCreateJob(
58 net::URLRequest* request, 63 net::URLRequest* request,
59 net::NetworkDelegate* network_delegate) = 0; 64 net::NetworkDelegate* network_delegate) = 0;
60 65
61 protected: 66 protected:
62 ServiceWorkerRequestHandler( 67 ServiceWorkerRequestHandler(
63 base::WeakPtr<ServiceWorkerContextCore> context, 68 base::WeakPtr<ServiceWorkerContextCore> context,
64 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 69 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
70 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context,
65 ResourceType::Type resource_type); 71 ResourceType::Type resource_type);
66 72
67 base::WeakPtr<ServiceWorkerContextCore> context_; 73 base::WeakPtr<ServiceWorkerContextCore> context_;
68 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; 74 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
75 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context_;
69 ResourceType::Type resource_type_; 76 ResourceType::Type resource_type_;
70 77
71 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); 78 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler);
72 }; 79 };
73 80
74 } // namespace content 81 } // namespace content
75 82
76 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ 83 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698