Implement SSLKEYLOGFILE for OpenSSL.
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_script_cache_map.h
blob45afcc3ba232e4de095df2d1c889a9c6944e24eb
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.
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CACHE_MAP_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CACHE_MAP_H_
8 #include <map>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/weak_ptr.h"
13 #include "content/browser/service_worker/service_worker_database.h"
14 #include "content/common/content_export.h"
16 class GURL;
18 namespace content {
20 class ServiceWorkerContextCore;
21 class ServiceWorkerVersion;
23 // Class that maintains the mapping between urls and a resource id
24 // for a particular version's implicit script resources.
25 class CONTENT_EXPORT ServiceWorkerScriptCacheMap {
26 public:
27 int64 Lookup(const GURL& url);
29 // Used during the initial run of a new version to build the map
30 // of resources ids.
31 void NotifyStartedCaching(const GURL& url, int64 resource_id);
32 void NotifyFinishedCaching(const GURL& url, bool success);
34 // Used to retrieve the results of the initial run of a new version.
35 bool HasError() const { return has_error_; }
36 void GetResources(
37 std::vector<ServiceWorkerDatabase::ResourceRecord>* resources);
39 // Used when loading an existing version.
40 void SetResources(
41 const std::vector<ServiceWorkerDatabase::ResourceRecord>& resources);
43 size_t size() const { return resource_ids_.size(); }
45 private:
46 typedef std::map<GURL, int64> ResourceIDMap;
48 // The version objects owns its script cache and provides a rawptr to it.
49 friend class ServiceWorkerVersion;
50 ServiceWorkerScriptCacheMap(
51 ServiceWorkerVersion* owner,
52 base::WeakPtr<ServiceWorkerContextCore> context);
53 ~ServiceWorkerScriptCacheMap();
55 ServiceWorkerVersion* owner_;
56 base::WeakPtr<ServiceWorkerContextCore> context_;
57 ResourceIDMap resource_ids_;
58 bool has_error_;
60 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptCacheMap);
63 } // namespace content
65 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CACHE_MAP_H_