Chromium Code Reviews| Index: content/public/browser/service_worker_context.cc |
| diff --git a/content/public/browser/service_worker_context.cc b/content/public/browser/service_worker_context.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1b5753d430ece95d4061752adb39c0a9cd8003ef |
| --- /dev/null |
| +++ b/content/public/browser/service_worker_context.cc |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/public/browser/service_worker_context.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/lazy_instance.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +namespace content { |
| + |
| +namespace { |
| + |
| +typedef std::set<std::string> HeaderNameSet; |
| +static base::LazyInstance<HeaderNameSet> g_excluded_header_name_set = |
|
Lei Zhang
2014/10/29 21:47:21
you: you don't need static in an anonymous namespa
horo
2014/10/30 07:54:34
Done.
|
| + LAZY_INSTANCE_INITIALIZER; |
| +} |
| + |
|
no sievers
2014/10/29 21:19:58
Do you think the static functions could move to th
horo
2014/10/30 07:54:34
ServiceWorkerContextWrapper which is the impl clas
no sievers
2014/10/30 19:35:33
Oh I meant just literally moving the definition of
|
| +void ServiceWorkerContext::AddExcludedHeadersForFetchEvent( |
| + const std::vector<std::string>& header_names) { |
| + if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| + BrowserThread::PostTask( |
|
no sievers
2014/10/29 21:19:58
Could you let the caller handle that? Then you can
horo
2014/10/30 07:54:34
Done.
|
| + BrowserThread::IO, |
| + FROM_HERE, |
| + base::Bind(ServiceWorkerContext::AddExcludedHeadersForFetchEvent, |
| + header_names)); |
| + return; |
| + } |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + g_excluded_header_name_set.Get().insert(header_names.begin(), |
| + header_names.end()); |
| +} |
| + |
| +bool ServiceWorkerContext::IsExcludedHeaderNameForFetchEvent( |
| + const std::string& header_name) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + return g_excluded_header_name_set.Get().find(header_name) != |
| + g_excluded_header_name_set.Get().end(); |
| +} |
| + |
| +} // namespace content |