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

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

Issue 360123002: ServiceWorker: some more groundwork in support of the update process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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_REGISTER_JOB_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void AddCallback(const RegistrationCallback& callback, int process_id); 55 void AddCallback(const RegistrationCallback& callback, int process_id);
56 56
57 // ServiceWorkerRegisterJobBase implementation: 57 // ServiceWorkerRegisterJobBase implementation:
58 virtual void Start() OVERRIDE; 58 virtual void Start() OVERRIDE;
59 virtual void Abort() OVERRIDE; 59 virtual void Abort() OVERRIDE;
60 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE; 60 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE;
61 virtual RegistrationJobType GetType() OVERRIDE; 61 virtual RegistrationJobType GetType() OVERRIDE;
62 62
63 private: 63 private:
64 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest, 64 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest,
65 AssociateWaitingVersionToDocuments); 65 AssociateInstallingVersionToDocuments);
66 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest, 66 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest,
67 DisassociateWaitingVersionFromDocuments); 67 DisassociateVersionFromDocuments);
68 68
69 enum Phase { 69 enum Phase {
70 INITIAL, 70 INITIAL,
71 START, 71 START,
72 REGISTER, 72 REGISTER,
73 UPDATE, 73 UPDATE,
74 INSTALL, 74 INSTALL,
75 STORE, 75 STORE,
76 ACTIVATE, 76 ACTIVATE,
77 COMPLETE, 77 COMPLETE,
78 ABORT, 78 ABORT,
79 }; 79 };
80 80
81 // Holds internal state of ServiceWorkerRegistrationJob, to compel use of the 81 // Holds internal state of ServiceWorkerRegistrationJob, to compel use of the
82 // getter/setter functions. 82 // getter/setter functions.
83 struct Internal { 83 struct Internal {
84 Internal(); 84 Internal();
85 ~Internal(); 85 ~Internal();
86 scoped_refptr<ServiceWorkerRegistration> registration; 86 scoped_refptr<ServiceWorkerRegistration> registration;
87 87
88 // Holds 'installing' or 'waiting' version depending on the phase. 88 // Holds 'installing' or 'waiting' version depending on the phase.
89 scoped_refptr<ServiceWorkerVersion> pending_version; 89 scoped_refptr<ServiceWorkerVersion> new_version;
90 }; 90 };
91 91
92 void set_registration(ServiceWorkerRegistration* registration); 92 void set_registration(ServiceWorkerRegistration* registration);
93 ServiceWorkerRegistration* registration(); 93 ServiceWorkerRegistration* registration();
94 void set_pending_version(ServiceWorkerVersion* version); 94 void set_new_version(ServiceWorkerVersion* version);
95 ServiceWorkerVersion* pending_version(); 95 ServiceWorkerVersion* new_version();
96 96
97 void SetPhase(Phase phase); 97 void SetPhase(Phase phase);
98 98
99 void HandleExistingRegistrationAndContinue( 99 void HandleExistingRegistrationAndContinue(
100 ServiceWorkerStatusCode status, 100 ServiceWorkerStatusCode status,
101 const scoped_refptr<ServiceWorkerRegistration>& registration); 101 const scoped_refptr<ServiceWorkerRegistration>& registration);
102 void RegisterAndContinue(ServiceWorkerStatusCode status); 102 void RegisterAndContinue(ServiceWorkerStatusCode status);
103 void UpdateAndContinue(ServiceWorkerStatusCode status); 103 void UpdateAndContinue(ServiceWorkerStatusCode status);
104 void OnStartWorkerFinished(ServiceWorkerStatusCode status); 104 void OnStartWorkerFinished(ServiceWorkerStatusCode status);
105 void OnStoreRegistrationComplete(ServiceWorkerStatusCode status); 105 void OnStoreRegistrationComplete(ServiceWorkerStatusCode status);
106 void InstallAndContinue(); 106 void InstallAndContinue();
107 void OnInstallFinished(ServiceWorkerStatusCode status); 107 void OnInstallFinished(ServiceWorkerStatusCode status);
108 void ActivateAndContinue(); 108 void ActivateAndContinue();
109 void OnActivateFinished(ServiceWorkerStatusCode status); 109 void OnActivateFinished(ServiceWorkerStatusCode status);
110 void Complete(ServiceWorkerStatusCode status); 110 void Complete(ServiceWorkerStatusCode status);
111 void CompleteInternal(ServiceWorkerStatusCode status); 111 void CompleteInternal(ServiceWorkerStatusCode status);
112 112
113 void ResolvePromise(ServiceWorkerStatusCode status, 113 void ResolvePromise(ServiceWorkerStatusCode status,
114 ServiceWorkerRegistration* registration, 114 ServiceWorkerRegistration* registration,
115 ServiceWorkerVersion* version); 115 ServiceWorkerVersion* version);
116 116
117 // EmbeddedWorkerInstance::Listener override of OnPausedAfterDownload. 117 // EmbeddedWorkerInstance::Listener override of OnPausedAfterDownload.
118 virtual void OnPausedAfterDownload() OVERRIDE; 118 virtual void OnPausedAfterDownload() OVERRIDE;
119 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 119 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
120 120
121 // Associates a waiting version to documents matched with a scope of the 121 // Associates a waiting version to documents matched with a scope of the
falken 2014/07/02 05:42:11 "an installing version"
122 // version. 122 // version.
123 CONTENT_EXPORT static void AssociateWaitingVersionToDocuments( 123 CONTENT_EXPORT static void AssociateInstallingVersionToDocuments(
124 base::WeakPtr<ServiceWorkerContextCore> context, 124 base::WeakPtr<ServiceWorkerContextCore> context,
125 ServiceWorkerVersion* version); 125 ServiceWorkerVersion* version);
126 126
127 // Disassociates a waiting version specified by |version_id| from documents. 127 // Disassociates a version specified by |version_id| from documents.
128 CONTENT_EXPORT static void DisassociateWaitingVersionFromDocuments( 128 CONTENT_EXPORT static void DisassociateVersionFromDocuments(
129 base::WeakPtr<ServiceWorkerContextCore> context, 129 base::WeakPtr<ServiceWorkerContextCore> context,
130 int64 version_id); 130 ServiceWorkerVersion* version);
131 131
132 // The ServiceWorkerContextCore object should always outlive this. 132 // The ServiceWorkerContextCore object should always outlive this.
133 base::WeakPtr<ServiceWorkerContextCore> context_; 133 base::WeakPtr<ServiceWorkerContextCore> context_;
134 134
135 const GURL pattern_; 135 const GURL pattern_;
136 const GURL script_url_; 136 const GURL script_url_;
137 std::vector<RegistrationCallback> callbacks_; 137 std::vector<RegistrationCallback> callbacks_;
138 std::vector<int> pending_process_ids_; 138 std::vector<int> pending_process_ids_;
139 Phase phase_; 139 Phase phase_;
140 Internal internal_; 140 Internal internal_;
141 bool is_promise_resolved_; 141 bool is_promise_resolved_;
142 ServiceWorkerStatusCode promise_resolved_status_; 142 ServiceWorkerStatusCode promise_resolved_status_;
143 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_; 143 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_;
144 scoped_refptr<ServiceWorkerVersion> promise_resolved_version_; 144 scoped_refptr<ServiceWorkerVersion> promise_resolved_version_;
145 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; 145 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_;
146 146
147 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); 147 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob);
148 }; 148 };
149 149
150 } // namespace content 150 } // namespace content
151 151
152 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ 152 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698