blob: ef91713293d730b1dad181a658942da975a0c21e [file] [log] [blame]
Ben Chanc46c4552013-06-10 18:55:13 -07001// Copyright (c) 2013 The Chromium OS 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 MIST_CONFIG_LOADER_H_
6#define MIST_CONFIG_LOADER_H_
7
8#include <base/basictypes.h>
9#include <base/file_path.h>
10#include <base/memory/scoped_ptr.h>
11#include <gtest/gtest_prod.h>
12
13namespace mist {
14
15class Config;
16class UsbModemInfo;
17
18// A configuration file loader, which loads information about USB modems
19// supported by mist from a configuration file based on the text format of
20// protocol buffers. The protocol buffers for the configuration file are defined
21// in proto/*.proto.
22class ConfigLoader {
23 public:
24 ConfigLoader();
25 ~ConfigLoader();
26
27 // Loads a configuration from |config_file|. Returns true on success.
28 bool LoadConfig(const base::FilePath& config_file);
29
30 // Returns the info of the USB modem with its vendor ID equal to |vendor_id|
31 // and its product ID equal to |product_id| from the loaded configuration.
32 // Returns NULL if no matching USB modem is found. The returned UsbModemInfo
33 // object becomes invalid, and thus should not be held, beyond the lifetime
34 // of the loaded configuration held by |config_|.
35 const UsbModemInfo* GetUsbModemInfo(uint16 vendor_id,
36 uint16 product_id) const;
37
38 private:
39 FRIEND_TEST(ConfigLoaderTest, GetUsbModemInfo);
40 FRIEND_TEST(ConfigLoaderTest, LoadEmptyConfigFile);
41 FRIEND_TEST(ConfigLoaderTest, LoadInvalidConfigFile);
42 FRIEND_TEST(ConfigLoaderTest, LoadNonExistentConfigFile);
43 FRIEND_TEST(ConfigLoaderTest, LoadValidConfigFile);
44
45 scoped_ptr<Config> config_;
46
47 DISALLOW_COPY_AND_ASSIGN(ConfigLoader);
48};
49
50} // namespace mist
51
52#endif // MIST_CONFIG_LOADER_H_