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

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

Issue 224733014: Introduce ServiceWorkerHandle for tracking WebServiceWorkerImpl reference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 18 matching lines...) Expand all
29 const base::FilePath& path, 29 const base::FilePath& path,
30 quota::QuotaManagerProxy* quota_manager_proxy) 30 quota::QuotaManagerProxy* quota_manager_proxy)
31 : last_registration_id_(0), // TODO(kinuko): this should be read from disk. 31 : last_registration_id_(0), // TODO(kinuko): this should be read from disk.
32 last_version_id_(0), // TODO(kinuko): this should be read from disk. 32 last_version_id_(0), // TODO(kinuko): this should be read from disk.
33 quota_manager_proxy_(quota_manager_proxy) { 33 quota_manager_proxy_(quota_manager_proxy) {
34 if (!path.empty()) 34 if (!path.empty())
35 path_ = path.Append(kServiceWorkerDirectory); 35 path_ = path.Append(kServiceWorkerDirectory);
36 } 36 }
37 37
38 ServiceWorkerStorage::~ServiceWorkerStorage() { 38 ServiceWorkerStorage::~ServiceWorkerStorage() {
39 // TODO(michaeln): fix the onwership model such that workers can get shutdown
40 // prior to browser close time.
41 for (PatternToRegistrationMap::const_iterator iter =
42 registration_by_pattern_.begin();
43 iter != registration_by_pattern_.end();
44 ++iter) {
45 iter->second->Shutdown();
46 }
47 registration_by_pattern_.clear(); 39 registration_by_pattern_.clear();
48 } 40 }
49 41
50 void ServiceWorkerStorage::FindRegistrationForPattern( 42 void ServiceWorkerStorage::FindRegistrationForPattern(
51 const GURL& pattern, 43 const GURL& pattern,
52 const FindRegistrationCallback& callback) { 44 const FindRegistrationCallback& callback) {
53 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_NOT_FOUND; 45 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_NOT_FOUND;
54 scoped_refptr<ServiceWorkerRegistration> found; 46 scoped_refptr<ServiceWorkerRegistration> found;
55 PatternToRegistrationMap::const_iterator match = 47 PatternToRegistrationMap::const_iterator match =
56 registration_by_pattern_.find(pattern); 48 registration_by_pattern_.find(pattern);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // Temporarily borrowed directly from appcache::Namespace::IsMatch(). 156 // Temporarily borrowed directly from appcache::Namespace::IsMatch().
165 // We have to escape '?' characters since MatchPattern also treats those 157 // We have to escape '?' characters since MatchPattern also treats those
166 // as wildcards which we don't want here, we only do '*'s. 158 // as wildcards which we don't want here, we only do '*'s.
167 std::string pattern_spec(pattern.spec()); 159 std::string pattern_spec(pattern.spec());
168 if (pattern.has_query()) 160 if (pattern.has_query())
169 ReplaceSubstringsAfterOffset(&pattern_spec, 0, "?", "\\?"); 161 ReplaceSubstringsAfterOffset(&pattern_spec, 0, "?", "\\?");
170 return MatchPattern(url.spec(), pattern_spec); 162 return MatchPattern(url.spec(), pattern_spec);
171 } 163 }
172 164
173 } // namespace content 165 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698