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

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

Issue 229403004: Assert about ServiceWorkerRegisterJob internal state in terms of phases (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ctor/dtor style error and bad merge 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
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_register_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // added via AddProcessToWorker to the ServiceWorkerVersion created by the 48 // added via AddProcessToWorker to the ServiceWorkerVersion created by the
49 // registration job. 49 // registration job.
50 void AddCallback(const RegistrationCallback& callback, int process_id); 50 void AddCallback(const RegistrationCallback& callback, int process_id);
51 51
52 // ServiceWorkerRegisterJobBase implementation: 52 // ServiceWorkerRegisterJobBase implementation:
53 virtual void Start() OVERRIDE; 53 virtual void Start() OVERRIDE;
54 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE; 54 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE;
55 virtual RegistrationJobType GetType() OVERRIDE; 55 virtual RegistrationJobType GetType() OVERRIDE;
56 56
57 private: 57 private:
58 enum Phase {
59 INITIAL,
60 START,
61 REGISTER,
62 UPDATE,
63 INSTALL,
64 ACTIVATE,
65 COMPLETE
66 };
67
68 // Holds internal state of ServiceWorkerRegistrationJob, to compel use of the
69 // getter/setter functions.
70 struct Internal {
71 Internal();
72 ~Internal();
73 scoped_refptr<ServiceWorkerRegistration> registration;
74 scoped_refptr<ServiceWorkerVersion> pending_version;
75 };
76
77 void set_registration(ServiceWorkerRegistration* registration);
78 ServiceWorkerRegistration* registration();
79 void set_pending_version(ServiceWorkerVersion* version);
80 ServiceWorkerVersion* pending_version();
81
82 void SetPhase(Phase phase);
83
58 void HandleExistingRegistrationAndContinue( 84 void HandleExistingRegistrationAndContinue(
59 ServiceWorkerStatusCode status, 85 ServiceWorkerStatusCode status,
60 const scoped_refptr<ServiceWorkerRegistration>& registration); 86 const scoped_refptr<ServiceWorkerRegistration>& registration);
61 void RegisterAndContinue(ServiceWorkerStatusCode status); 87 void RegisterAndContinue(ServiceWorkerStatusCode status);
62 void UpdateAndContinue(ServiceWorkerStatusCode status); 88 void UpdateAndContinue(ServiceWorkerStatusCode status);
63 void OnStartWorkerFinished(ServiceWorkerStatusCode status); 89 void OnStartWorkerFinished(ServiceWorkerStatusCode status);
64 void InstallAndContinue(); 90 void InstallAndContinue();
65 void OnInstallFinished(ServiceWorkerStatusCode status); 91 void OnInstallFinished(ServiceWorkerStatusCode status);
66 void ActivateAndContinue(); 92 void ActivateAndContinue();
67 void Complete(ServiceWorkerStatusCode status); 93 void Complete(ServiceWorkerStatusCode status);
68 94
69 void RunCallbacks(ServiceWorkerStatusCode status, 95 void RunCallbacks(ServiceWorkerStatusCode status,
70 ServiceWorkerRegistration* registration, 96 ServiceWorkerRegistration* registration,
71 ServiceWorkerVersion* version); 97 ServiceWorkerVersion* version);
72 98
73 // The ServiceWorkerStorage object should always outlive this. 99 // The ServiceWorkerContextCore object should always outlive this.
74 base::WeakPtr<ServiceWorkerContextCore> context_; 100 base::WeakPtr<ServiceWorkerContextCore> context_;
75 scoped_refptr<ServiceWorkerRegistration> registration_; 101
76 scoped_refptr<ServiceWorkerVersion> pending_version_;
77 const GURL pattern_; 102 const GURL pattern_;
78 const GURL script_url_; 103 const GURL script_url_;
79 std::vector<RegistrationCallback> callbacks_; 104 std::vector<RegistrationCallback> callbacks_;
80 std::vector<int> pending_process_ids_; 105 std::vector<int> pending_process_ids_;
106 Phase phase_;
107 Internal internal_;
81 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; 108 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_;
82 109
83 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); 110 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob);
84 }; 111 };
85 112
86 } // namespace content 113 } // namespace content
87 114
88 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ 115 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_register_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698