summaryrefslogtreecommitdiff
path: root/chromium/components/autofill/core/browser/region_data_loader.h
blob: 1e2fb87f68c2e80e14dfc34256f6e7c3844c57a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2017 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 COMPONENTS_AUTOFILL_CORE_BROWSER_REGION_DATA_LOADER_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_REGION_DATA_LOADER_H_

#include <string>
#include <vector>

#include "base/callback_forward.h"

namespace i18n {
namespace addressinput {
class RegionData;
}  // namespace addressinput
}  // namespace i18n

namespace autofill {

// An interface to wrap the loading of region data so it can be mocked in tests.
class RegionDataLoader {
 public:
  // The signature of the function to be called when the region data is loaded.
  // When the loading request times out or other failure occure, |regions| is
  // empty.
  typedef base::Callback<void(
      const std::vector<const ::i18n::addressinput::RegionData*>& regions)>
      RegionDataLoaded;

  virtual ~RegionDataLoader() {}
  // Calls |loaded_callback| when the region data for |country_code| is ready or
  // when |timeout_ms| miliseconds have passed. This may happen synchronously.
  virtual void LoadRegionData(const std::string& country_code,
                              RegionDataLoaded callback,
                              int64_t timeout_ms) = 0;
  // To forget about the |callback| givent to LoadRegionData, in cases where
  // callback owner is destroyed before loader.
  virtual void ClearCallback() = 0;
};

}  // namespace autofill

#endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_REGION_DATA_LOADER_H_