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

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

Issue 255413005: Mostly manual refactoring of ServiceWorkerRequestHandler into a base class and two derived classes,… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_PROVIDER_HOST_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "webkit/common/resource_type.h" 13 #include "webkit/common/resource_type.h"
14 14
15 namespace ipc { 15 namespace ipc {
16 class Sender; 16 class Sender;
17 } 17 }
18 18
19 namespace content { 19 namespace content {
20 20
21 class ServiceWorkerContextCore; 21 class ServiceWorkerContextCore;
22 class ServiceWorkerDispatcherHost; 22 class ServiceWorkerDispatcherHost;
23 class ServiceWorkerRequestHandler;
23 class ServiceWorkerVersion; 24 class ServiceWorkerVersion;
24 25
25 // This class is the browser-process representation of a serice worker 26 // This class is the browser-process representation of a serice worker
26 // provider. There is a provider per document and the lifetime of this 27 // provider. There is a provider per document and the lifetime of this
27 // object is tied to the lifetime of its document in the renderer process. 28 // object is tied to the lifetime of its document in the renderer process.
28 // This class holds service worker state this is scoped to an individual 29 // This class holds service worker state this is scoped to an individual
29 // document. 30 // document.
30 class CONTENT_EXPORT ServiceWorkerProviderHost 31 class CONTENT_EXPORT ServiceWorkerProviderHost
31 : public base::SupportsWeakPtr<ServiceWorkerProviderHost> { 32 : public base::SupportsWeakPtr<ServiceWorkerProviderHost> {
32 public: 33 public:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Associate |version| to this provider as its '.active' or '.pending' 73 // Associate |version| to this provider as its '.active' or '.pending'
73 // version. 74 // version.
74 // Giving NULL to this method will unset the corresponding field. 75 // Giving NULL to this method will unset the corresponding field.
75 void SetActiveVersion(ServiceWorkerVersion* version); 76 void SetActiveVersion(ServiceWorkerVersion* version);
76 void SetPendingVersion(ServiceWorkerVersion* version); 77 void SetPendingVersion(ServiceWorkerVersion* version);
77 78
78 // Returns false if the version is not in the expected STARTING in our 79 // Returns false if the version is not in the expected STARTING in our
79 // our process state. That would be indicative of a bad IPC message. 80 // our process state. That would be indicative of a bad IPC message.
80 bool SetHostedVersionId(int64 versions_id); 81 bool SetHostedVersionId(int64 versions_id);
81 82
82 // Returns true if this provider host should handle requests for 83 // Returns a handler for a request, the handler may return NULL if
83 // |resource_type|. 84 // the request doesn't require special handling.
84 bool ShouldHandleRequest(ResourceType::Type resource_type) const; 85 scoped_ptr<ServiceWorkerRequestHandler> CreateRequestHandler(
86 ResourceType::Type resource_type);
85 87
86 private: 88 private:
87 const int process_id_; 89 const int process_id_;
88 const int provider_id_; 90 const int provider_id_;
89 GURL document_url_; 91 GURL document_url_;
90 std::set<int> script_client_thread_ids_; 92 std::set<int> script_client_thread_ids_;
91 scoped_refptr<ServiceWorkerVersion> active_version_; 93 scoped_refptr<ServiceWorkerVersion> active_version_;
92 scoped_refptr<ServiceWorkerVersion> pending_version_; 94 scoped_refptr<ServiceWorkerVersion> pending_version_;
93 scoped_refptr<ServiceWorkerVersion> hosted_version_; 95 scoped_refptr<ServiceWorkerVersion> hosted_version_;
94 base::WeakPtr<ServiceWorkerContextCore> context_; 96 base::WeakPtr<ServiceWorkerContextCore> context_;
95 ServiceWorkerDispatcherHost* dispatcher_host_; 97 ServiceWorkerDispatcherHost* dispatcher_host_;
96 98
97 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); 99 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost);
98 }; 100 };
99 101
100 } // namespace content 102 } // namespace content
101 103
102 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ 104 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698