cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / policy / core / common / external_data_fetcher.h
blob25ea41a263a57815774aa246d5d1092323c1c854
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_EXTERNAL_DATA_FETCHER_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_EXTERNAL_DATA_FETCHER_H_
8 #include <string>
10 #include "base/callback_forward.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "components/policy/policy_export.h"
15 namespace policy {
17 class ExternalDataManager;
19 // A helper that encapsulates the parameters required to retrieve the external
20 // data for a policy.
21 class POLICY_EXPORT ExternalDataFetcher {
22 public:
23 typedef base::Callback<void(scoped_ptr<std::string>)> FetchCallback;
25 // This instance's Fetch() method will instruct the |manager| to retrieve the
26 // external data referenced by the given |policy|.
27 ExternalDataFetcher(base::WeakPtr<ExternalDataManager> manager,
28 const std::string& policy);
29 ExternalDataFetcher(const ExternalDataFetcher& other);
31 ~ExternalDataFetcher();
33 static bool Equals(const ExternalDataFetcher* first,
34 const ExternalDataFetcher* second);
36 // Retrieves the external data referenced by |policy_| and invokes |callback|
37 // with the result. If |policy_| does not reference any external data, the
38 // |callback| is invoked with a NULL pointer. Otherwise, the |callback| is
39 // invoked with the referenced data once it has been successfully retrieved.
40 // If retrieval is temporarily impossible (e.g. no network connectivity), the
41 // |callback| will be invoked when the temporary hindrance is resolved. If
42 // retrieval is permanently impossible (e.g. |policy_| references data that
43 // does not exist on the server), the |callback| will never be invoked.
44 void Fetch(const FetchCallback& callback) const;
46 private:
47 base::WeakPtr<ExternalDataManager> manager_;
48 const std::string policy_;
51 } // namespace policy
53 #endif // COMPONENTS_POLICY_CORE_COMMON_EXTERNAL_DATA_FETCHER_H_