blob: 58f619b22afa70c28a81ac0f13e1fd73d967692c [file] [log] [blame]
Paul Stewarte6927402012-01-23 16:11:30 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Chris Masone88cbd5f2011-07-03 14:30:04 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_DEFAULT_PROFILE_
6#define SHILL_DEFAULT_PROFILE_
7
8#include <string>
9#include <vector>
10
Chris Masone2ae797d2011-08-23 20:41:00 -070011#include <base/file_path.h>
Chris Masone88cbd5f2011-07-03 14:30:04 -070012#include <base/memory/scoped_ptr.h>
Chris Masoneaa482372011-09-14 16:40:37 -070013#include <gtest/gtest_prod.h> // for FRIEND_TEST
Chris Masone88cbd5f2011-07-03 14:30:04 -070014
Paul Stewart26b327e2011-10-19 11:38:09 -070015#include "shill/event_dispatcher.h"
Chris Masone88cbd5f2011-07-03 14:30:04 -070016#include "shill/manager.h"
17#include "shill/profile.h"
18#include "shill/property_store.h"
19#include "shill/refptr_types.h"
Chris Masone88cbd5f2011-07-03 14:30:04 -070020
21namespace shill {
22
23class ControlInterface;
24
25class DefaultProfile : public Profile {
26 public:
Chris Masone2ae797d2011-08-23 20:41:00 -070027 DefaultProfile(ControlInterface *control,
Chris Masone6791a432011-07-12 13:23:19 -070028 Manager *manager,
Chris Masone2ae797d2011-08-23 20:41:00 -070029 const FilePath &storage_path,
Chris Masone88cbd5f2011-07-03 14:30:04 -070030 const Manager::Properties &manager_props);
31 virtual ~DefaultProfile();
32
Paul Stewart870523b2012-01-11 17:00:42 -080033 // Loads global configuration into manager properties.
34 virtual bool LoadManagerProperties(Manager::Properties *manager_props);
35
Chris Masone877ff982011-09-21 16:18:24 -070036 // Persists profile information, as well as that of discovered devices
37 // and bound services, to disk.
38 // Returns true on success, false on failure.
Chris Masoneb9c00592011-10-06 13:10:39 -070039 virtual bool Save();
Chris Masoneaa482372011-09-14 16:40:37 -070040
Paul Stewart5dc40aa2011-10-28 19:43:43 -070041 protected:
Chris Masone2ae797d2011-08-23 20:41:00 -070042 // Sets |path| to the persistent store file path for the default, global
43 // profile. Returns true on success, and false if unable to determine an
44 // appropriate file location.
45 //
46 // In this implementation, |name_| is ignored.
47 virtual bool GetStoragePath(FilePath *path);
48
Chris Masone88cbd5f2011-07-03 14:30:04 -070049 private:
Paul Stewart870523b2012-01-11 17:00:42 -080050 friend class DefaultProfileTest;
Paul Stewart5dc40aa2011-10-28 19:43:43 -070051 FRIEND_TEST(DefaultProfileTest, GetStoragePath);
Paul Stewarte6927402012-01-23 16:11:30 -080052 FRIEND_TEST(DefaultProfileTest, LoadManagerDefaultProperties);
Paul Stewart870523b2012-01-11 17:00:42 -080053 FRIEND_TEST(DefaultProfileTest, LoadManagerProperties);
54 FRIEND_TEST(DefaultProfileTest, Save);
Chris Masoneaa482372011-09-14 16:40:37 -070055
Chris Masone7df0c672011-07-15 10:24:54 -070056 static const char kDefaultId[];
Chris Masoneaa482372011-09-14 16:40:37 -070057 static const char kStorageId[];
58 static const char kStorageCheckPortalList[];
Paul Stewartd32f4842012-01-11 16:08:13 -080059 static const char kStorageHostName[];
Chris Masoneaa482372011-09-14 16:40:37 -070060 static const char kStorageName[];
61 static const char kStorageOfflineMode[];
Paul Stewarte6927402012-01-23 16:11:30 -080062 static const char kStoragePortalURL[];
Chris Masone7df0c672011-07-15 10:24:54 -070063
Chris Masone2ae797d2011-08-23 20:41:00 -070064 const FilePath storage_path_;
Chris Masoneaa482372011-09-14 16:40:37 -070065 const Manager::Properties &props_;
Chris Masone2ae797d2011-08-23 20:41:00 -070066
Chris Masone88cbd5f2011-07-03 14:30:04 -070067 DISALLOW_COPY_AND_ASSIGN(DefaultProfile);
68};
69
70} // namespace shill
71
72#endif // SHILL_DEFAULT_PROFILE_