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

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

Issue 182383008: Create chrome://serviceworker-internals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix GetInfo / const stuff 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 #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
9 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "content/browser/service_worker/service_worker_info.h"
11 #include "content/browser/service_worker/service_worker_registration.h" 11 #include "content/browser/service_worker/service_worker_registration.h"
12 #include "content/public/browser/browser_thread.h"
12 #include "webkit/browser/quota/quota_manager_proxy.h" 13 #include "webkit/browser/quota/quota_manager_proxy.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 namespace { 17 namespace {
17 18
18 void RunSoon(const base::Closure& closure) { 19 void RunSoon(const base::Closure& closure) {
19 base::MessageLoop::current()->PostTask(FROM_HERE, closure); 20 base::MessageLoop::current()->PostTask(FROM_HERE, closure);
20 } 21 }
21 22
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (PatternMatches(it->first, document_url)) { 74 if (PatternMatches(it->first, document_url)) {
74 status = SERVICE_WORKER_OK; 75 status = SERVICE_WORKER_OK;
75 found = it->second; 76 found = it->second;
76 break; 77 break;
77 } 78 }
78 } 79 }
79 // Always simulate asynchronous call for now. 80 // Always simulate asynchronous call for now.
80 RunSoon(base::Bind(callback, status, found)); 81 RunSoon(base::Bind(callback, status, found));
81 } 82 }
82 83
84 void ServiceWorkerStorage::GetAllRegistrations(
85 const GetAllRegistrationInfosCallback& callback) {
86 std::vector<ServiceWorkerRegistrationInfo> registrations;
87 for (PatternToRegistrationMap::const_iterator it =
88 registration_by_pattern_.begin();
89 it != registration_by_pattern_.end();
90 ++it) {
91 ServiceWorkerRegistration* registration(it->second.get());
92 registrations.push_back(registration->GetInfo());
93 }
94
95 BrowserThread::PostTask(
96 BrowserThread::IO, FROM_HERE, base::Bind(callback, registrations));
97 }
98
83 void ServiceWorkerStorage::StoreRegistration( 99 void ServiceWorkerStorage::StoreRegistration(
84 ServiceWorkerRegistration* registration, 100 ServiceWorkerRegistration* registration,
85 const StatusCallback& callback) { 101 const StatusCallback& callback) {
86 DCHECK(registration); 102 DCHECK(registration);
87 103
88 PatternToRegistrationMap::const_iterator current( 104 PatternToRegistrationMap::const_iterator current(
89 registration_by_pattern_.find(registration->pattern())); 105 registration_by_pattern_.find(registration->pattern()));
90 if (current != registration_by_pattern_.end() && 106 if (current != registration_by_pattern_.end() &&
91 current->second->script_url() != registration->script_url()) { 107 current->second->script_url() != registration->script_url()) {
92 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_EXISTS)); 108 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_EXISTS));
(...skipping 30 matching lines...) Expand all
123 // Temporarily borrowed directly from appcache::Namespace::IsMatch(). 139 // Temporarily borrowed directly from appcache::Namespace::IsMatch().
124 // We have to escape '?' characters since MatchPattern also treats those 140 // We have to escape '?' characters since MatchPattern also treats those
125 // as wildcards which we don't want here, we only do '*'s. 141 // as wildcards which we don't want here, we only do '*'s.
126 std::string pattern_spec(pattern.spec()); 142 std::string pattern_spec(pattern.spec());
127 if (pattern.has_query()) 143 if (pattern.has_query())
128 ReplaceSubstringsAfterOffset(&pattern_spec, 0, "?", "\\?"); 144 ReplaceSubstringsAfterOffset(&pattern_spec, 0, "?", "\\?");
129 return MatchPattern(url.spec(), pattern_spec); 145 return MatchPattern(url.spec(), pattern_spec);
130 } 146 }
131 147
132 } // namespace content 148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698