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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « components/policy.gypi ('k') | components/policy/core/browser/policy_header_io_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 #ifndef COMPONENTS_POLICY_CORE_BROWSER_POLICY_HEADER_IO_HELPER_H_
6 #define COMPONENTS_POLICY_CORE_BROWSER_POLICY_HEADER_IO_HELPER_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/sequenced_task_runner.h"
12 #include "components/policy/policy_export.h"
13
14 namespace net {
15 class URLRequest;
16 }
17
18 namespace policy {
19
20 // Helper class that lives on the I/O thread and adds policy headers to
21 // outgoing requests. Instances of this class are created by
22 // PolicyHeaderService on the UI thread, and that class is responsible for
23 // notifying this class via UpdateHeaderFromUI() when the header changes.
24 // Ownership is transferred to ProfileIOData, and this object is run and
25 // destroyed on the I/O thread.
26 class POLICY_EXPORT PolicyHeaderIOHelper {
27 public:
28 PolicyHeaderIOHelper(
29 const std::string& server_url,
30 const std::string& initial_header_value,
31 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
32 ~PolicyHeaderIOHelper();
33
34 // Sets any necessary policy headers on the passed request. Should be invoked
35 // only from the I/O thread.
36 void AddPolicyHeaders(net::URLRequest* request) const;
37
38 // API invoked when the header changes. Can be called from any thread - calls
39 // are marshalled via the TaskRunner to run on the appropriate thread.
40 // If |new_header| is the empty string, no header will be added to
41 // outgoing requests.
42 void UpdateHeader(const std::string& new_header);
43
44 private:
45 // API invoked via the TaskRunner to update the header.
46 void UpdateHeaderOnIOThread(const std::string& new_header);
47
48 // The URL we should add policy headers to.
49 std::string server_url_;
50
51 // The task runner assocated with the I/O thread that runs this object.
52 scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
53
54 // The current policy header value.
55 std::string policy_header_;
56
57 DISALLOW_COPY_AND_ASSIGN(PolicyHeaderIOHelper);
58 };
59
60 } // namespace policy
61
62 #endif // COMPONENTS_POLICY_CORE_BROWSER_POLICY_HEADER_IO_HELPER_H_
OLDNEW
« 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