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

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

Issue 280423005: Adds class ServiceWorkerScriptCacheMap and new ServiceWorkerVersion::Listener methods related to sc… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_SCRIPT_CACHE_MAP_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_SCRIPT_CACHE_MAP_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "base/observer_list.h"
12
13 class GURL;
14
15 namespace content {
16
17 class ServiceWorkerVersion;
18
19 // Class that maintains the mapping between urls and a resource id
20 // for a particular versions implicit script resources.
21 class ServiceWorkerScriptCacheMap {
22 public:
23 class Observer {
24 public:
25 // Notification that the main script resource has been written to
26 // the disk cache. Only called when a version is being initially
27 // installed.
28 virtual void OnMainScriptCached(ServiceWorkerVersion* version,
29 bool success) = 0;
30
31 // Notification that the main script resource and all imports have
32 // been written to the disk cache. Only called when a version is
33 // being initially installed.
34 virtual void OnAllScriptsCached(ServiceWorkerVersion* version,
35 bool success) = 0;
36 };
37
38 int64 Lookup(const GURL& url);
39
40 // Adds and removes Observers.
41 void AddObserver(Observer* observer);
42 void RemoveObserver(Observer* observer);
43
44 // Used during the initial run of a new version to build the map
45 // of resources ids.
46 // TODO(michaeln): Need more info about errors in Finished.
47 void NotifyStartedCaching(const GURL& url, int64 resource_id);
48 void NotifyFinishedCaching(const GURL& url, bool success);
49 void NotifyEvalCompletion();
50
51 private:
52 typedef std::map<GURL, int64> ResourceIDMap;
53
54 // The version objects owns its script cache and provides a rawptr to it.
55 friend class ServiceWorkerVersion;
56 explicit ServiceWorkerScriptCacheMap(ServiceWorkerVersion* owner);
57 ~ServiceWorkerScriptCacheMap();
58
59 ServiceWorkerVersion* owner_;
60 ResourceIDMap resource_ids_;
61
62 // Members used only during initial install.
63 bool is_eval_complete_;
64 int resources_started_;
65 int resources_finished_;
66 bool has_error_;
67 ObserverList<Observer> observers_;
68
69 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptCacheMap);
70 };
71
72 } // namespace content
73
74 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_SCRIPT_CACHE_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698