cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / policy / core / common / cloud / policy_header_service.h
blobf0bc4a99893ddf11489e870332448be49af2183c
1 // Copyright 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.
5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_POLICY_HEADER_SERVICE_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_POLICY_HEADER_SERVICE_H_
8 #include <string>
9 #include <vector>
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/policy/core/common/cloud/cloud_policy_store.h"
14 #include "components/policy/policy_export.h"
16 namespace base {
17 class SequencedTaskRunner;
20 namespace policy {
22 class PolicyHeaderIOHelper;
24 // Per-profile service used to generate PolicyHeaderIOHelper objects, and
25 // keep them up-to-date as policy changes.
26 // TODO(atwilson): Move to components/policy once CloudPolicyStore is moved.
27 class POLICY_EXPORT PolicyHeaderService : public CloudPolicyStore::Observer {
28 public:
29 // |device_policy_store| can be null on platforms that do not support
30 // device policy. Both |user_policy_store| and |device_policy_store| must
31 // outlive this object.
32 PolicyHeaderService(const std::string& server_url,
33 const std::string& verification_key_hash,
34 CloudPolicyStore* user_policy_store,
35 CloudPolicyStore* device_policy_store);
36 ~PolicyHeaderService() override;
38 // Creates a PolicyHeaderIOHelper object to be run on the IO thread and
39 // add policy headers to outgoing requests. The caller takes ownership of
40 // this object and must ensure it outlives ProfileHeaderService (in practice,
41 // this is called by ProfileIOData, which is shutdown *after* all
42 // ProfileKeyedServices are shutdown).
43 scoped_ptr<PolicyHeaderIOHelper> CreatePolicyHeaderIOHelper(
44 scoped_refptr<base::SequencedTaskRunner> task_runner);
46 // Overridden CloudPolicyStore::Observer methods:
47 void OnStoreLoaded(CloudPolicyStore* store) override;
48 void OnStoreError(CloudPolicyStore* store) override;
50 // Returns a list of all PolicyHeaderIOHelpers created by this object.
51 std::vector<PolicyHeaderIOHelper*> GetHelpersForTest();
53 private:
54 // Generate a policy header based on the currently loaded policy.
55 std::string CreateHeaderValue();
57 // Weak pointer to created PolicyHeaderIOHelper objects.
58 std::vector<PolicyHeaderIOHelper*> helpers_;
60 // URL of the policy server.
61 std::string server_url_;
63 // Identifier for the verification key this Chrome instance is using.
64 std::string verification_key_hash_;
66 // Weak pointers to User-/Device-level policy stores.
67 CloudPolicyStore* user_policy_store_;
68 CloudPolicyStore* device_policy_store_;
70 DISALLOW_COPY_AND_ASSIGN(PolicyHeaderService);
73 } // namespace policy
75 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_POLICY_HEADER_SERVICE_H_