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

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

Issue 397933003: Service Workers: Clean up cpplint.py warnings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 #include "content/browser/service_worker/service_worker_storage.h" 5 #include "content/browser/service_worker/service_worker_storage.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/task_runner_util.h" 13 #include "base/task_runner_util.h"
14 #include "content/browser/service_worker/service_worker_context_core.h" 14 #include "content/browser/service_worker/service_worker_context_core.h"
15 #include "content/browser/service_worker/service_worker_disk_cache.h" 15 #include "content/browser/service_worker/service_worker_disk_cache.h"
16 #include "content/browser/service_worker/service_worker_info.h" 16 #include "content/browser/service_worker/service_worker_info.h"
17 #include "content/browser/service_worker/service_worker_metrics.h" 17 #include "content/browser/service_worker/service_worker_metrics.h"
18 #include "content/browser/service_worker/service_worker_registration.h" 18 #include "content/browser/service_worker/service_worker_registration.h"
19 #include "content/browser/service_worker/service_worker_utils.h" 19 #include "content/browser/service_worker/service_worker_utils.h"
20 #include "content/browser/service_worker/service_worker_version.h" 20 #include "content/browser/service_worker/service_worker_version.h"
21 #include "content/common/service_worker/service_worker_types.h" 21 #include "content/common/service_worker/service_worker_types.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "net/base/completion_callback.h"
23 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
24 #include "webkit/browser/quota/quota_manager_proxy.h" 25 #include "webkit/browser/quota/quota_manager_proxy.h"
25 26
26 namespace content { 27 namespace content {
27 28
28 namespace { 29 namespace {
29 30
30 void RunSoon(const tracked_objects::Location& from_here, 31 void RunSoon(const tracked_objects::Location& from_here,
31 const base::Closure& closure) { 32 const base::Closure& closure) {
32 base::MessageLoop::current()->PostTask(from_here, closure); 33 base::MessageLoop::current()->PostTask(from_here, closure);
(...skipping 17 matching lines...) Expand all
50 const base::FilePath::CharType kServiceWorkerDirectory[] = 51 const base::FilePath::CharType kServiceWorkerDirectory[] =
51 FILE_PATH_LITERAL("Service Worker"); 52 FILE_PATH_LITERAL("Service Worker");
52 const base::FilePath::CharType kDatabaseName[] = 53 const base::FilePath::CharType kDatabaseName[] =
53 FILE_PATH_LITERAL("Database"); 54 FILE_PATH_LITERAL("Database");
54 const base::FilePath::CharType kDiskCacheName[] = 55 const base::FilePath::CharType kDiskCacheName[] =
55 FILE_PATH_LITERAL("Cache"); 56 FILE_PATH_LITERAL("Cache");
56 57
57 const int kMaxMemDiskCacheSize = 10 * 1024 * 1024; 58 const int kMaxMemDiskCacheSize = 10 * 1024 * 1024;
58 const int kMaxDiskCacheSize = 250 * 1024 * 1024; 59 const int kMaxDiskCacheSize = 250 * 1024 * 1024;
59 60
60 void EmptyCompletionCallback(int) {}
61
62 ServiceWorkerStatusCode DatabaseStatusToStatusCode( 61 ServiceWorkerStatusCode DatabaseStatusToStatusCode(
63 ServiceWorkerDatabase::Status status) { 62 ServiceWorkerDatabase::Status status) {
64 switch (status) { 63 switch (status) {
65 case ServiceWorkerDatabase::STATUS_OK: 64 case ServiceWorkerDatabase::STATUS_OK:
66 return SERVICE_WORKER_OK; 65 return SERVICE_WORKER_OK;
67 case ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND: 66 case ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND:
68 return SERVICE_WORKER_ERROR_NOT_FOUND; 67 return SERVICE_WORKER_ERROR_NOT_FOUND;
69 case ServiceWorkerDatabase::STATUS_ERROR_MAX: 68 case ServiceWorkerDatabase::STATUS_ERROR_MAX:
70 NOTREACHED(); 69 NOTREACHED();
71 default: 70 default:
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 } 815 }
817 816
818 ServiceWorkerDiskCache* ServiceWorkerStorage::disk_cache() { 817 ServiceWorkerDiskCache* ServiceWorkerStorage::disk_cache() {
819 if (disk_cache_) 818 if (disk_cache_)
820 return disk_cache_.get(); 819 return disk_cache_.get();
821 820
822 disk_cache_.reset(new ServiceWorkerDiskCache); 821 disk_cache_.reset(new ServiceWorkerDiskCache);
823 822
824 base::FilePath path = GetDiskCachePath(); 823 base::FilePath path = GetDiskCachePath();
825 if (path.empty()) { 824 if (path.empty()) {
826 int rv = disk_cache_->InitWithMemBackend( 825 int rv = disk_cache_->InitWithMemBackend(kMaxMemDiskCacheSize,
827 kMaxMemDiskCacheSize, 826 net::CompletionCallback());
828 base::Bind(&EmptyCompletionCallback));
829 DCHECK_EQ(net::OK, rv); 827 DCHECK_EQ(net::OK, rv);
830 return disk_cache_.get(); 828 return disk_cache_.get();
831 } 829 }
832 830
833 int rv = disk_cache_->InitWithDiskBackend( 831 int rv = disk_cache_->InitWithDiskBackend(
834 path, kMaxDiskCacheSize, false, 832 path, kMaxDiskCacheSize, false,
835 disk_cache_thread_.get(), 833 disk_cache_thread_.get(),
836 base::Bind(&ServiceWorkerStorage::OnDiskCacheInitialized, 834 base::Bind(&ServiceWorkerStorage::OnDiskCacheInitialized,
837 weak_factory_.GetWeakPtr())); 835 weak_factory_.GetWeakPtr()));
838 if (rv != net::ERR_IO_PENDING) 836 if (rv != net::ERR_IO_PENDING)
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 // Give up the corruption recovery until the browser restarts. 1174 // Give up the corruption recovery until the browser restarts.
1177 LOG(ERROR) << "Failed to delete the diskcache."; 1175 LOG(ERROR) << "Failed to delete the diskcache.";
1178 callback.Run(SERVICE_WORKER_ERROR_FAILED); 1176 callback.Run(SERVICE_WORKER_ERROR_FAILED);
1179 return; 1177 return;
1180 } 1178 }
1181 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; 1179 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully.";
1182 callback.Run(SERVICE_WORKER_OK); 1180 callback.Run(SERVICE_WORKER_OK);
1183 } 1181 }
1184 1182
1185 } // namespace content 1183 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698