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

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: Rebase fixes 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 #include <vector> 9 #include <vector>
10 10
(...skipping 20 matching lines...) Expand all
31 public: 31 public:
32 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; 32 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback;
33 typedef base::Callback<void(ServiceWorkerStatusCode status, 33 typedef base::Callback<void(ServiceWorkerStatusCode status,
34 const scoped_refptr<ServiceWorkerRegistration>& 34 const scoped_refptr<ServiceWorkerRegistration>&
35 registration)> FindRegistrationCallback; 35 registration)> FindRegistrationCallback;
36 36
37 ServiceWorkerStorage(const base::FilePath& path, 37 ServiceWorkerStorage(const base::FilePath& path,
38 quota::QuotaManagerProxy* quota_manager_proxy); 38 quota::QuotaManagerProxy* quota_manager_proxy);
39 ~ServiceWorkerStorage(); 39 ~ServiceWorkerStorage();
40 40
41 // Finds registration for |document_url| or |pattern|. 41 // Finds registration for |document_url| or |pattern| or |registraion_id|.
marja 2014/03/17 09:15:02 Nit: typo
jsbell 2014/03/17 16:49:06 Done.
42 // Returns SERVICE_WORKER_OK with non-null registration if registration 42 // Returns SERVICE_WORKER_OK with non-null registration if registration
43 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching 43 // is found, or returns SERVICE_WORKER_ERROR_NOT_FOUND if no matching
44 // registration is found. 44 // registration is found.
45 void FindRegistrationForDocument(const GURL& document_url, 45 void FindRegistrationForDocument(const GURL& document_url,
46 const FindRegistrationCallback& callback); 46 const FindRegistrationCallback& callback);
47 void FindRegistrationForPattern(const GURL& pattern, 47 void FindRegistrationForPattern(const GURL& pattern,
48 const FindRegistrationCallback& callback); 48 const FindRegistrationCallback& callback);
49 void FindRegistrationForId(int64 registration_id,
50 const FindRegistrationCallback& callback);
49 51
50 typedef base::Callback< 52 typedef base::Callback<
51 void(const std::vector<ServiceWorkerRegistrationInfo>& registrations)> 53 void(const std::vector<ServiceWorkerRegistrationInfo>& registrations)>
52 GetAllRegistrationInfosCallback; 54 GetAllRegistrationInfosCallback;
53 void GetAllRegistrations(const GetAllRegistrationInfosCallback& callback); 55 void GetAllRegistrations(const GetAllRegistrationInfosCallback& callback);
54 56
55 // Stores |registration|. Returns SERVICE_WORKER_ERROR_EXISTS if 57 // Stores |registration|. Returns SERVICE_WORKER_ERROR_EXISTS if
56 // conflicting registration (which has different script_url) is 58 // conflicting registration (which has different script_url) is
57 // already registered for the |registration|->pattern(). 59 // already registered for the |registration|->pattern().
58 void StoreRegistration(ServiceWorkerRegistration* registration, 60 void StoreRegistration(ServiceWorkerRegistration* registration,
59 const StatusCallback& callback); 61 const StatusCallback& callback);
60 62
61 // Deletes |registration|. This may return SERVICE_WORKER_ERROR_NOT_FOUND 63 // Deletes |registration|. This may return SERVICE_WORKER_ERROR_NOT_FOUND
62 // if no matching registration is found. 64 // if no matching registration is found.
63 void DeleteRegistration(const GURL& pattern, 65 void DeleteRegistration(const GURL& pattern,
64 const StatusCallback& callback); 66 const StatusCallback& callback);
65 67
66 // Returns new IDs which are guaranteed to be unique in the storage. 68 // Returns new IDs which are guaranteed to be unique in the storage.
67 int64 NewRegistrationId(); 69 int64 NewRegistrationId();
68 int64 NewVersionId(); 70 int64 NewVersionId();
69 71
70 private: 72 private:
71 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerStorageTest, PatternMatches); 73 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerStorageTest, PatternMatches);
72 74
73 typedef std::map<GURL, scoped_refptr<ServiceWorkerRegistration> > 75 typedef std::map<GURL, scoped_refptr<ServiceWorkerRegistration> >
74 PatternToRegistrationMap; 76 PatternToRegistrationMap;
77 typedef std::map<int64, scoped_refptr<ServiceWorkerRegistration> >
78 RegistrationIdToRegistrationMap;
75 79
76 static bool PatternMatches(const GURL& pattern, const GURL& script_url); 80 static bool PatternMatches(const GURL& pattern, const GURL& script_url);
77 81
78 // This is the in-memory registration. Eventually the registration will be 82 // This is the in-memory registration. Eventually the registration will be
79 // persisted to disk. 83 // persisted to disk.
80 PatternToRegistrationMap registration_by_pattern_; 84 PatternToRegistrationMap registration_by_pattern_;
81 85
82 int last_registration_id_; 86 int last_registration_id_;
83 int last_version_id_; 87 int last_version_id_;
84 88
85 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 89 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
86 base::FilePath path_; 90 base::FilePath path_;
87 91
88 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); 92 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage);
89 }; 93 };
90 94
91 } // namespace content 95 } // namespace content
92 96
93 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ 97 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698