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

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

Issue 189253002: Implement ServiceWorker::postMessage() [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename message handler per review feedback 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 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "content/browser/service_worker/service_worker_info.h" 10 #include "content/browser/service_worker/service_worker_info.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 it != registration_by_pattern_.end(); 90 it != registration_by_pattern_.end();
91 ++it) { 91 ++it) {
92 ServiceWorkerRegistration* registration(it->second.get()); 92 ServiceWorkerRegistration* registration(it->second.get());
93 registrations.push_back(registration->GetInfo()); 93 registrations.push_back(registration->GetInfo());
94 } 94 }
95 95
96 BrowserThread::PostTask( 96 BrowserThread::PostTask(
97 BrowserThread::IO, FROM_HERE, base::Bind(callback, registrations)); 97 BrowserThread::IO, FROM_HERE, base::Bind(callback, registrations));
98 } 98 }
99 99
100 void ServiceWorkerStorage::FindRegistrationForId(
101 int64 registration_id,
102 const FindRegistrationCallback& callback) {
103 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_NOT_FOUND;
104 scoped_refptr<ServiceWorkerRegistration> found;
105 for (PatternToRegistrationMap::const_iterator it =
106 registration_by_pattern_.begin();
107 it != registration_by_pattern_.end();
108 ++it) {
109 if (registration_id == it->second->id()) {
110 status = SERVICE_WORKER_OK;
111 found = it->second;
112 break;
113 }
114 }
115 RunSoon(base::Bind(callback, status, found));
116 }
117
100 void ServiceWorkerStorage::StoreRegistration( 118 void ServiceWorkerStorage::StoreRegistration(
101 ServiceWorkerRegistration* registration, 119 ServiceWorkerRegistration* registration,
102 const StatusCallback& callback) { 120 const StatusCallback& callback) {
103 DCHECK(registration); 121 DCHECK(registration);
104 122
105 PatternToRegistrationMap::const_iterator current( 123 PatternToRegistrationMap::const_iterator current(
106 registration_by_pattern_.find(registration->pattern())); 124 registration_by_pattern_.find(registration->pattern()));
107 if (current != registration_by_pattern_.end() && 125 if (current != registration_by_pattern_.end() &&
108 current->second->script_url() != registration->script_url()) { 126 current->second->script_url() != registration->script_url()) {
109 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_EXISTS)); 127 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_EXISTS));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Temporarily borrowed directly from appcache::Namespace::IsMatch(). 162 // Temporarily borrowed directly from appcache::Namespace::IsMatch().
145 // We have to escape '?' characters since MatchPattern also treats those 163 // We have to escape '?' characters since MatchPattern also treats those
146 // as wildcards which we don't want here, we only do '*'s. 164 // as wildcards which we don't want here, we only do '*'s.
147 std::string pattern_spec(pattern.spec()); 165 std::string pattern_spec(pattern.spec());
148 if (pattern.has_query()) 166 if (pattern.has_query())
149 ReplaceSubstringsAfterOffset(&pattern_spec, 0, "?", "\\?"); 167 ReplaceSubstringsAfterOffset(&pattern_spec, 0, "?", "\\?");
150 return MatchPattern(url.spec(), pattern_spec); 168 return MatchPattern(url.spec(), pattern_spec);
151 } 169 }
152 170
153 } // namespace content 171 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_storage.h ('k') | content/child/service_worker/service_worker_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698