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

Unified Diff: components/policy/core/browser/policy_header_io_helper.h

Issue 99433004: Add a header when fetching pages under the DMServer URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed per willchan's feedback Created 7 years 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
« no previous file with comments | « components/policy.gypi ('k') | components/policy/core/browser/policy_header_io_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/browser/policy_header_io_helper.h
diff --git a/components/policy/core/browser/policy_header_io_helper.h b/components/policy/core/browser/policy_header_io_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..68665c4b0a17f09955bc8502c2b134738f6d8904
--- /dev/null
+++ b/components/policy/core/browser/policy_header_io_helper.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2013 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.
+
+#ifndef COMPONENTS_POLICY_CORE_BROWSER_POLICY_HEADER_IO_HELPER_H_
+#define COMPONENTS_POLICY_CORE_BROWSER_POLICY_HEADER_IO_HELPER_H_
+
+#include <string>
+
+#include "base/memory/ref_counted.h"
+#include "base/sequenced_task_runner.h"
+#include "components/policy/policy_export.h"
+
+namespace net {
+class URLRequest;
+}
+
+namespace policy {
+
+// Helper class that lives on the I/O thread and adds policy headers to
+// outgoing requests. Instances of this class are created by
+// PolicyHeaderService on the UI thread, and that class is responsible for
+// notifying this class via UpdateHeaderFromUI() when the header changes.
+// Ownership is transferred to ProfileIOData, and this object is run and
+// destroyed on the I/O thread.
+class POLICY_EXPORT PolicyHeaderIOHelper {
+ public:
+ PolicyHeaderIOHelper(
+ const std::string& server_url,
+ const std::string& initial_header_value,
+ const scoped_refptr<base::SequencedTaskRunner>& task_runner);
+ ~PolicyHeaderIOHelper();
+
+ // Sets any necessary policy headers on the passed request. Should be invoked
+ // only from the I/O thread.
+ void AddPolicyHeaders(net::URLRequest* request) const;
+
+ // API invoked when the header changes. Can be called from any thread - calls
+ // are marshalled via the TaskRunner to run on the appropriate thread.
+ // If |new_header| is the empty string, no header will be added to
+ // outgoing requests.
+ void UpdateHeader(const std::string& new_header);
+
+ private:
+ // API invoked via the TaskRunner to update the header.
+ void UpdateHeaderOnIOThread(const std::string& new_header);
+
+ // The URL we should add policy headers to.
+ std::string server_url_;
+
+ // The task runner assocated with the I/O thread that runs this object.
+ scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
+
+ // The current policy header value.
+ std::string policy_header_;
+
+ DISALLOW_COPY_AND_ASSIGN(PolicyHeaderIOHelper);
+};
+
+} // namespace policy
+
+#endif // COMPONENTS_POLICY_CORE_BROWSER_POLICY_HEADER_IO_HELPER_H_
« no previous file with comments | « components/policy.gypi ('k') | components/policy/core/browser/policy_header_io_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698