OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_fetch_stores_manager.h" | 5 #include "content/browser/service_worker/service_worker_fetch_stores_manager.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
12 #include "base/sha1.h" | 12 #include "base/sha1.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "content/browser/service_worker/service_worker_context_core.h" | 15 #include "content/browser/service_worker/service_worker_context_core.h" |
16 #include "content/browser/service_worker/service_worker_fetch_stores.h" | 16 #include "content/browser/service_worker/service_worker_fetch_stores.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 base::FilePath ConstructOriginPath(const base::FilePath& root_path, | 22 base::FilePath ConstructOriginPath(const base::FilePath& root_path, |
23 const GURL& origin) { | 23 const GURL& origin) { |
24 std::string origin_hash = base::SHA1HashString(origin.spec()); | 24 std::string origin_hash = base::SHA1HashString(origin.spec()); |
25 std::string origin_hash_hex = StringToLowerASCII( | 25 std::string origin_hash_hex = base::StringToLowerASCII( |
26 base::HexEncode(origin_hash.c_str(), origin_hash.length())); | 26 base::HexEncode(origin_hash.c_str(), origin_hash.length())); |
27 return root_path.AppendASCII(origin_hash_hex); | 27 return root_path.AppendASCII(origin_hash_hex); |
28 } | 28 } |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 namespace content { | 32 namespace content { |
33 | 33 |
34 // static | 34 // static |
35 scoped_ptr<ServiceWorkerFetchStoresManager> | 35 scoped_ptr<ServiceWorkerFetchStoresManager> |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 backend, | 160 backend, |
161 base::MessageLoopProxy::current()); | 161 base::MessageLoopProxy::current()); |
162 // The map owns fetch_stores. | 162 // The map owns fetch_stores. |
163 service_worker_fetch_stores_.insert(std::make_pair(origin, fetch_stores)); | 163 service_worker_fetch_stores_.insert(std::make_pair(origin, fetch_stores)); |
164 return fetch_stores; | 164 return fetch_stores; |
165 } | 165 } |
166 return it->second; | 166 return it->second; |
167 } | 167 } |
168 | 168 |
169 } // namespace content | 169 } // namespace content |
OLD | NEW |