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

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

Issue 189253002: Implement ServiceWorker::postMessage() [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback Created 6 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 | 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_STORAGE_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 18 matching lines...) Expand all
29 public: 29 public:
30 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; 30 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback;
31 typedef base::Callback<void(ServiceWorkerStatusCode status, 31 typedef base::Callback<void(ServiceWorkerStatusCode status,
32 const scoped_refptr<ServiceWorkerRegistration>& 32 const scoped_refptr<ServiceWorkerRegistration>&
33 registration)> FindRegistrationCallback; 33 registration)> FindRegistrationCallback;
34 34
35 ServiceWorkerStorage(const base::FilePath& path, 35 ServiceWorkerStorage(const base::FilePath& path,
36 quota::QuotaManagerProxy* quota_manager_proxy); 36 quota::QuotaManagerProxy* quota_manager_proxy);
37 ~ServiceWorkerStorage(); 37 ~ServiceWorkerStorage();
38 38
39 // Finds registration for |document_url| or |pattern|. 39 // Finds registration for |document_url| or |pattern| or |registraion_id|.
40 // Returns SERVICE_WORKER_OK with non-null registration if registration 40 // Returns SERVICE_WORKER_OK with non-null registration if registration
41 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching 41 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching
42 // registration is found. 42 // registration is found.
43 void FindRegistrationForDocument(const GURL& document_url, 43 void FindRegistrationForDocument(const GURL& document_url,
44 const FindRegistrationCallback& callback); 44 const FindRegistrationCallback& callback);
45 void FindRegistrationForPattern(const GURL& pattern, 45 void FindRegistrationForPattern(const GURL& pattern,
46 const FindRegistrationCallback& callback); 46 const FindRegistrationCallback& callback);
47 void FindRegistrationForId(int64 registration_id,
48 const FindRegistrationCallback& callback);
47 49
48 // Stores |registration|. Returns SERVICE_WORKER_ERROR_EXISTS if 50 // Stores |registration|. Returns SERVICE_WORKER_ERROR_EXISTS if
49 // conflicting registration (which has different script_url) is 51 // conflicting registration (which has different script_url) is
50 // already registered for the |registration|->pattern(). 52 // already registered for the |registration|->pattern().
51 void StoreRegistration(ServiceWorkerRegistration* registration, 53 void StoreRegistration(ServiceWorkerRegistration* registration,
52 const StatusCallback& callback); 54 const StatusCallback& callback);
53 55
54 // Deletes |registration|. This may return SERVICE_WORKER_ERROR_NOT_FOUND 56 // Deletes |registration|. This may return SERVICE_WORKER_ERROR_NOT_FOUND
55 // if no matching registration is found. 57 // if no matching registration is found.
56 void DeleteRegistration(const GURL& pattern, 58 void DeleteRegistration(const GURL& pattern,
57 const StatusCallback& callback); 59 const StatusCallback& callback);
58 60
59 // Returns new IDs which are guaranteed to be unique in the storage. 61 // Returns new IDs which are guaranteed to be unique in the storage.
60 int64 NewRegistrationId(); 62 int64 NewRegistrationId();
61 int64 NewVersionId(); 63 int64 NewVersionId();
62 64
63 private: 65 private:
64 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerStorageTest, PatternMatches); 66 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerStorageTest, PatternMatches);
65 67
66 typedef std::map<GURL, scoped_refptr<ServiceWorkerRegistration> > 68 typedef std::map<GURL, scoped_refptr<ServiceWorkerRegistration> >
67 PatternToRegistrationMap; 69 PatternToRegistrationMap;
70 typedef std::map<int64, scoped_refptr<ServiceWorkerRegistration> >
71 RegistrationIdToRegistrationMap;
68 72
69 static bool PatternMatches(const GURL& pattern, const GURL& script_url); 73 static bool PatternMatches(const GURL& pattern, const GURL& script_url);
70 74
71 // This is the in-memory registration. Eventually the registration will be 75 // This is the in-memory registration. Eventually the registration will be
72 // persisted to disk. 76 // persisted to disk.
73 PatternToRegistrationMap registration_by_pattern_; 77 PatternToRegistrationMap registration_by_pattern_;
74 78
75 int last_registration_id_; 79 int last_registration_id_;
76 int last_version_id_; 80 int last_version_id_;
77 81
78 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 82 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
79 base::FilePath path_; 83 base::FilePath path_;
80 84
81 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); 85 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage);
82 }; 86 };
83 87
84 } // namespace content 88 } // namespace content
85 89
86 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ 90 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698