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

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

Issue 998173002: Revise ServiceWorker DevTools protocols. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use DCHECK_CURRENTLY_ON Created 5 years, 9 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_
7
8 #include <vector>
9
10 #include "base/callback.h"
11 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "content/browser/service_worker/service_worker_context_observer.h"
13 #include "content/browser/service_worker/service_worker_info.h"
14
15 namespace content {
16
17 class ServiceWorkerContextWrapper;
18
19 // Used to monitor the status change of the ServiceWorker registrations and
20 // versions in the ServiceWorkerContext from UI thread.
21 class ServiceWorkerContextWatcher
22 : public ServiceWorkerContextObserver,
23 public base::RefCountedThreadSafe<ServiceWorkerContextWatcher> {
24 public:
25 typedef base::Callback<void(
26 const std::vector<ServiceWorkerRegistrationInfo>&)>
27 WorkerRegistrationUpdatedCallback;
28 typedef base::Callback<void(const std::vector<ServiceWorkerVersionInfo>&)>
29 WorkerVersionUpdatedCallback;
30 ServiceWorkerContextWatcher(
31 scoped_refptr<ServiceWorkerContextWrapper> context,
32 const WorkerRegistrationUpdatedCallback& registration_callback,
33 const WorkerVersionUpdatedCallback& version_callback);
34 void Start();
35 void Stop();
36
37 private:
38 friend class base::RefCountedThreadSafe<ServiceWorkerContextWatcher>;
39 ~ServiceWorkerContextWatcher() override;
40
41 void GetStoredRegistrationsOnIOThread();
42 void OnStoredRegistrationsOnIOThread(
43 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations);
44 void StopOnIOThread();
45
46 void StoreRegistrationInfo(
47 const ServiceWorkerRegistrationInfo& registration,
48 base::ScopedPtrHashMap<int64, ServiceWorkerRegistrationInfo>* info_map);
49 void StoreVersionInfo(const ServiceWorkerVersionInfo& version);
50
51 void SendRegistrationInfo(
52 int64 registration_id,
53 const GURL& pattern,
54 ServiceWorkerRegistrationInfo::DeleteFlag delete_flag);
55 void SendVersionInfo(const ServiceWorkerVersionInfo& version);
56
57 // ServiceWorkerContextObserver implements
58 void OnNewLiveRegistration(int64 registration_id,
59 const GURL& pattern) override;
60 void OnNewLiveVersion(int64 version_id,
61 int64 registration_id,
62 const GURL& script_url) override;
63 void OnRunningStateChanged(
64 int64 version_id,
65 content::ServiceWorkerVersion::RunningStatus running_status) override;
66 void OnVersionStateChanged(
67 int64 version_id,
68 content::ServiceWorkerVersion::Status status) override;
69 void OnRegistrationStored(int64 registration_id,
70 const GURL& pattern) override;
71 void OnRegistrationDeleted(int64 registration_id,
72 const GURL& pattern) override;
73
74 base::ScopedPtrHashMap<int64, ServiceWorkerVersionInfo> version_info_map_;
75 scoped_refptr<ServiceWorkerContextWrapper> context_;
76 WorkerRegistrationUpdatedCallback registration_callback_;
77 WorkerVersionUpdatedCallback version_callback_;
78 };
79
80 } // namespace content
81
82 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698