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

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: Whitespace fix. 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
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 #include "base/memory/ref_counted.h"
Joao da Silva 2013/12/09 14:46:21 nit: usually a newline is left between <system> an
Andrew T Wilson (Slow) 2013/12/10 07:15:56 Done.
10 #include "base/memory/weak_ptr.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(const std::string& server_url,
29 const std::string& initial_header_value,
30 scoped_refptr<base::SequencedTaskRunner> task_runner);
31 ~PolicyHeaderIOHelper();
32
33 // Sets any necessary policy headers on the passed request. Should be invoked
34 // only from the I/O thread.
35 void AddPolicyHeaders(net::URLRequest* request) const;
36
37 // API invoked when the header changes. Should only be called on the UI
38 // thread. If |new_header| is the empty string, no header will be added to
39 // outgoing requests.
40 void UpdateHeaderFromUI(const std::string& new_header);
41
42 private:
43 // API invoked on the I/O thread to update the header.
44 void UpdateHeaderOnIO(const std::string& new_header);
45
46 // The URL we should add policy headers to.
47 std::string server_url_;
48
49 // The task runner assocated with the thread that runs this object.
50 scoped_refptr<base::SequencedTaskRunner> task_runner_;
51
52 // The current policy header value.
53 std::string policy_header_;
54
55 base::WeakPtrFactory<PolicyHeaderIOHelper> weak_factory_;
56 DISALLOW_COPY_AND_ASSIGN(PolicyHeaderIOHelper);
57 };
58
59 } // namespace policy
60
61 #endif // COMPONENTS_POLICY_CORE_BROWSER_POLICY_HEADER_IO_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698