Chromium Code Reviews| Index: chrome/browser/policy/cloud/policy_header_service.h |
| diff --git a/chrome/browser/policy/cloud/policy_header_service.h b/chrome/browser/policy/cloud/policy_header_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7e955db21f85e484c58d96beff33db790b280042 |
| --- /dev/null |
| +++ b/chrome/browser/policy/cloud/policy_header_service.h |
| @@ -0,0 +1,67 @@ |
| +// 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 CHROME_BROWSER_POLICY_CLOUD_POLICY_HEADER_SERVICE_H_ |
| +#define CHROME_BROWSER_POLICY_CLOUD_POLICY_HEADER_SERVICE_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "components/policy/core/common/cloud/cloud_policy_store.h" |
| + |
| +namespace base { |
| +class SequencedTaskRunner; |
| +} |
| + |
| +namespace policy { |
| + |
| +class PolicyHeaderIOHelper; |
| + |
| +// Per-profile service used to generate PolicyHeaderIOHelper objects, and |
| +// keep them up-to-date as policy changes. |
| +// TODO(atwilson): Move to components/policy once CloudPolicyStore is moved. |
| +class PolicyHeaderService : public CloudPolicyStore::Observer { |
| + public: |
| + // |device_policy_store| can be null on platforms that do not support |
| + // device policy. Both |user_policy_store| and |device_policy_store| must |
| + // outlive this object. |
| + PolicyHeaderService(const std::string& server_url, |
| + CloudPolicyStore* user_policy_store, |
| + CloudPolicyStore* device_policy_store); |
| + virtual ~PolicyHeaderService(); |
| + |
| + // Creates a PolicyHeaderIOHelper object to be run on the IO thread and |
|
dconnelly
2013/12/09 12:47:35
Here and elsewhere I would prefer to eliminate the
Andrew T Wilson (Slow)
2013/12/10 07:15:56
Done.
|
| + // add policy headers to outgoing requests. The caller takes ownership of |
| + // this object and must ensure it outlives ProfileHeaderService (in practice, |
| + // this is called by ProfileIOData, which is shutdown *after* all |
| + // ProfileKeyedServices are shutdown). |
| + scoped_ptr<PolicyHeaderIOHelper> CreatePolicyHeaderIOHelper( |
| + scoped_refptr<base::SequencedTaskRunner> task_runner); |
| + |
| + // Overridden CloudPolicyStore::Observer methods: |
| + virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; |
| + virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; |
| + |
| + protected: |
| + // Generate a policy header based on the currently loaded policy. |
| + // Virtual to allow mocking in tests. |
| + virtual std::string CreateHeaderValue(); |
| + |
| + private: |
| + // Weak pointer to created PolicyHeaderIOHelper objects. |
| + std::vector<PolicyHeaderIOHelper*> helpers_; |
| + |
| + // URL of the policy server. |
| + std::string server_url_; |
| + |
| + // Weak pointers to User-/Device-level policy stores. |
| + CloudPolicyStore* user_policy_store_; |
| + CloudPolicyStore* device_policy_store_; |
| +}; |
| + |
| +} // namespace policy |
| + |
| +#endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_HEADER_SERVICE_H_ |