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

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: Reup 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 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (PatternMatches(it->first, document_url)) { 73 if (PatternMatches(it->first, document_url)) {
74 status = SERVICE_WORKER_OK; 74 status = SERVICE_WORKER_OK;
75 found = it->second; 75 found = it->second;
76 break; 76 break;
77 } 77 }
78 } 78 }
79 // Always simulate asynchronous call for now. 79 // Always simulate asynchronous call for now.
80 RunSoon(base::Bind(callback, status, found)); 80 RunSoon(base::Bind(callback, status, found));
81 } 81 }
82 82
83 void ServiceWorkerStorage::FindRegistrationForId(
84 int64 registration_id,
85 const FindRegistrationCallback& callback) {
86 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_NOT_FOUND;
87 scoped_refptr<ServiceWorkerRegistration> found;
88 for (PatternToRegistrationMap::const_iterator it =
89 registration_by_pattern_.begin();
90 it != registration_by_pattern_.end();
91 ++it) {
92 if (registration_id == it->second->id()) {
93 status = SERVICE_WORKER_OK;
94 found = it->second;
95 break;
96 }
97 }
98 RunSoon(base::Bind(callback, status, found));
99 }
100
83 void ServiceWorkerStorage::StoreRegistration( 101 void ServiceWorkerStorage::StoreRegistration(
84 ServiceWorkerRegistration* registration, 102 ServiceWorkerRegistration* registration,
85 const StatusCallback& callback) { 103 const StatusCallback& callback) {
86 DCHECK(registration); 104 DCHECK(registration);
87 105
88 PatternToRegistrationMap::const_iterator current( 106 PatternToRegistrationMap::const_iterator current(
89 registration_by_pattern_.find(registration->pattern())); 107 registration_by_pattern_.find(registration->pattern()));
90 if (current != registration_by_pattern_.end() && 108 if (current != registration_by_pattern_.end() &&
91 current->second->script_url() != registration->script_url()) { 109 current->second->script_url() != registration->script_url()) {
92 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_EXISTS)); 110 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_EXISTS));
(...skipping 30 matching lines...) Expand all
123 // Temporarily borrowed directly from appcache::Namespace::IsMatch(). 141 // Temporarily borrowed directly from appcache::Namespace::IsMatch().
124 // We have to escape '?' characters since MatchPattern also treats those 142 // We have to escape '?' characters since MatchPattern also treats those
125 // as wildcards which we don't want here, we only do '*'s. 143 // as wildcards which we don't want here, we only do '*'s.
126 std::string pattern_spec(pattern.spec()); 144 std::string pattern_spec(pattern.spec());
127 if (pattern.has_query()) 145 if (pattern.has_query())
128 ReplaceSubstringsAfterOffset(&pattern_spec, 0, "?", "\\?"); 146 ReplaceSubstringsAfterOffset(&pattern_spec, 0, "?", "\\?");
129 return MatchPattern(url.spec(), pattern_spec); 147 return MatchPattern(url.spec(), pattern_spec);
130 } 148 }
131 149
132 } // namespace content 150 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698