| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/public/browser/service_worker_context.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/lazy_instance.h" |
| 9 #include "content/public/browser/browser_thread.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 namespace { |
| 14 |
| 15 typedef std::set<std::string> HeaderNameSet; |
| 16 static base::LazyInstance<HeaderNameSet> g_excluded_header_name_set = |
| 17 LAZY_INSTANCE_INITIALIZER; |
| 18 } |
| 19 |
| 20 void ServiceWorkerContext::AddExcludedHeadersForFetchEvent( |
| 21 const std::vector<std::string> header_names) { |
| 22 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 23 BrowserThread::PostTask( |
| 24 BrowserThread::IO, |
| 25 FROM_HERE, |
| 26 base::Bind(ServiceWorkerContext::AddExcludedHeadersForFetchEvent, |
| 27 header_names)); |
| 28 return; |
| 29 } |
| 30 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 31 g_excluded_header_name_set.Get().insert(header_names.begin(), |
| 32 header_names.end()); |
| 33 } |
| 34 |
| 35 bool ServiceWorkerContext::IsExcludedHeaderNameForFetchEvent( |
| 36 const std::string& header_name) { |
| 37 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 38 return g_excluded_header_name_set.Get().find(header_name) != |
| 39 g_excluded_header_name_set.Get().end(); |
| 40 } |
| 41 |
| 42 } // namespace content |
| OLD | NEW |