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

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

Issue 647953003: Service Worker script sizes in database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Fixed crash where writer_ was null Created 6 years, 2 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_DATABASE_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 // Versions are first stored once they successfully install and become 58 // Versions are first stored once they successfully install and become
59 // the waiting version. Then transition to the active version. The stored 59 // the waiting version. Then transition to the active version. The stored
60 // version may be in the ACTIVATED state or in the INSTALLED state. 60 // version may be in the ACTIVATED state or in the INSTALLED state.
61 GURL script; 61 GURL script;
62 int64 version_id; 62 int64 version_id;
63 bool is_active; 63 bool is_active;
64 bool has_fetch_handler; 64 bool has_fetch_handler;
65 base::Time last_update_check; 65 base::Time last_update_check;
66 66
67 // Not populated until ServiceWorkerStorage::StoreRegistration is called.
68 uint64 resources_total_size_bytes;
69
67 RegistrationData(); 70 RegistrationData();
68 ~RegistrationData(); 71 ~RegistrationData();
69 }; 72 };
70 73
71 struct ResourceRecord { 74 struct ResourceRecord {
72 int64 resource_id; 75 int64 resource_id;
73 GURL url; 76 GURL url;
77 // Signed so we can store -1 to specify an unknown or error state. When
78 // stored to the database, this value should always be >= 0.
79 int64 size_bytes;
74 80
75 ResourceRecord() {} 81 ResourceRecord() : resource_id(-1), size_bytes(0) {}
76 ResourceRecord(int64 id, GURL url) : resource_id(id), url(url) {} 82 ResourceRecord(int64 id, GURL url, int64 size_bytes)
83 : resource_id(id), url(url), size_bytes(size_bytes) {}
77 }; 84 };
78 85
79 // Reads next available ids from the database. Returns OK if they are 86 // Reads next available ids from the database. Returns OK if they are
80 // successfully read. Fills the arguments with an initial value and returns 87 // successfully read. Fills the arguments with an initial value and returns
81 // OK if they are not found in the database. Otherwise, returns an error. 88 // OK if they are not found in the database. Otherwise, returns an error.
82 Status GetNextAvailableIds( 89 Status GetNextAvailableIds(
83 int64* next_avail_registration_id, 90 int64* next_avail_registration_id,
84 int64* next_avail_version_id, 91 int64* next_avail_version_id,
85 int64* next_avail_resource_id); 92 int64* next_avail_resource_id);
86 93
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion); 331 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DatabaseVersion);
325 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds); 332 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, GetNextAvailableIds);
326 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase); 333 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase);
327 334
328 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); 335 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase);
329 }; 336 };
330 337
331 } // namespace content 338 } // namespace content
332 339
333 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ 340 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698