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

Side by Side Diff: content/browser/service_worker/service_worker_version.cc

Issue 672813002: [ServiceWorker] Added size deltas and total size computation for QuotaM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed last comment Created 6 years, 1 month 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 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 #include "content/browser/service_worker/service_worker_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "content/browser/service_worker/embedded_worker_instance.h" 10 #include "content/browser/service_worker/embedded_worker_instance.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 ServiceWorkerVersion::ServiceWorkerVersion( 92 ServiceWorkerVersion::ServiceWorkerVersion(
93 ServiceWorkerRegistration* registration, 93 ServiceWorkerRegistration* registration,
94 const GURL& script_url, 94 const GURL& script_url,
95 int64 version_id, 95 int64 version_id,
96 base::WeakPtr<ServiceWorkerContextCore> context) 96 base::WeakPtr<ServiceWorkerContextCore> context)
97 : version_id_(version_id), 97 : version_id_(version_id),
98 registration_id_(kInvalidServiceWorkerVersionId), 98 registration_id_(kInvalidServiceWorkerVersionId),
99 script_url_(script_url), 99 script_url_(script_url),
100 status_(NEW), 100 status_(NEW),
101 resources_total_size_bytes_(0),
101 context_(context), 102 context_(context),
102 script_cache_map_(this, context), 103 script_cache_map_(this, context),
103 is_doomed_(false), 104 is_doomed_(false),
104 weak_factory_(this) { 105 weak_factory_(this) {
105 DCHECK(context_); 106 DCHECK(context_);
106 DCHECK(registration); 107 DCHECK(registration);
107 if (registration) { 108 if (registration) {
108 registration_id_ = registration->id(); 109 registration_id_ = registration->id();
109 scope_ = registration->pattern(); 110 scope_ = registration->pattern();
111 set_resources_total_size_bytes(registration->resources_total_size_bytes());
110 } 112 }
111 context_->AddLiveVersion(this); 113 context_->AddLiveVersion(this);
112 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); 114 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker();
113 embedded_worker_->AddListener(this); 115 embedded_worker_->AddListener(this);
114 } 116 }
115 117
116 ServiceWorkerVersion::~ServiceWorkerVersion() { 118 ServiceWorkerVersion::~ServiceWorkerVersion() {
117 embedded_worker_->RemoveListener(this); 119 embedded_worker_->RemoveListener(this);
118 if (context_) 120 if (context_)
119 context_->RemoveLiveVersion(version_id_); 121 context_->RemoveLiveVersion(version_id_);
(...skipping 27 matching lines...) Expand all
147 149
148 ServiceWorkerVersionInfo ServiceWorkerVersion::GetInfo() { 150 ServiceWorkerVersionInfo ServiceWorkerVersion::GetInfo() {
149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
150 return ServiceWorkerVersionInfo( 152 return ServiceWorkerVersionInfo(
151 running_status(), 153 running_status(),
152 status(), 154 status(),
153 script_url(), 155 script_url(),
154 version_id(), 156 version_id(),
155 embedded_worker()->process_id(), 157 embedded_worker()->process_id(),
156 embedded_worker()->thread_id(), 158 embedded_worker()->thread_id(),
157 embedded_worker()->worker_devtools_agent_route_id()); 159 embedded_worker()->worker_devtools_agent_route_id(),
160 resources_total_size_bytes_);
158 } 161 }
159 162
160 void ServiceWorkerVersion::StartWorker(const StatusCallback& callback) { 163 void ServiceWorkerVersion::StartWorker(const StatusCallback& callback) {
161 StartWorker(false, callback); 164 StartWorker(false, callback);
162 } 165 }
163 166
164 void ServiceWorkerVersion::StartWorker( 167 void ServiceWorkerVersion::StartWorker(
165 bool pause_after_download, 168 bool pause_after_download,
166 const StatusCallback& callback) { 169 const StatusCallback& callback) {
167 switch (running_status()) { 170 switch (running_status()) {
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 SetStatus(REDUNDANT); 698 SetStatus(REDUNDANT);
696 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 699 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
697 if (!context_) 700 if (!context_)
698 return; 701 return;
699 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; 702 std::vector<ServiceWorkerDatabase::ResourceRecord> resources;
700 script_cache_map_.GetResources(&resources); 703 script_cache_map_.GetResources(&resources);
701 context_->storage()->PurgeResources(resources); 704 context_->storage()->PurgeResources(resources);
702 } 705 }
703 706
704 } // namespace content 707 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698