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

Unified Diff: content/public/browser/service_worker_context.cc

Issue 666973003: [ServiceWorker] Don't send the UMA related headers to the ServiceWorker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use const ref Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698