Paul Stewart | e692740 | 2012-01-23 16:11:30 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 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 SHILL_DEFAULT_PROFILE_ |
| 6 | #define SHILL_DEFAULT_PROFILE_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 11 | #include <base/file_path.h> |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 12 | #include <base/memory/scoped_ptr.h> |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 13 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 14 | |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 15 | #include "shill/event_dispatcher.h" |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 16 | #include "shill/manager.h" |
| 17 | #include "shill/profile.h" |
| 18 | #include "shill/property_store.h" |
| 19 | #include "shill/refptr_types.h" |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 20 | |
| 21 | namespace shill { |
| 22 | |
| 23 | class ControlInterface; |
| 24 | |
| 25 | class DefaultProfile : public Profile { |
| 26 | public: |
Paul Stewart | d0a3b81 | 2012-03-28 22:48:22 -0700 | [diff] [blame] | 27 | static const char kDefaultId[]; |
| 28 | |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 29 | DefaultProfile(ControlInterface *control, |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 30 | Manager *manager, |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 31 | const FilePath &storage_path, |
Paul Stewart | d0a3b81 | 2012-03-28 22:48:22 -0700 | [diff] [blame] | 32 | const std::string &profile_id, |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 33 | const Manager::Properties &manager_props); |
| 34 | virtual ~DefaultProfile(); |
| 35 | |
Paul Stewart | 4d5efb7 | 2012-09-17 12:24:34 -0700 | [diff] [blame] | 36 | // Loads global configuration into manager properties. This should |
| 37 | // only be called by the Manager. |
Paul Stewart | 870523b | 2012-01-11 17:00:42 -0800 | [diff] [blame] | 38 | virtual bool LoadManagerProperties(Manager::Properties *manager_props); |
| 39 | |
Paul Stewart | f284a23 | 2012-05-01 10:24:37 -0700 | [diff] [blame] | 40 | // Override the Profile superclass implementation to accept all Ethernet |
| 41 | // services, since these should have an affinity for the default profile. |
| 42 | virtual bool ConfigureService(const ServiceRefPtr &service); |
| 43 | |
Chris Masone | 877ff98 | 2011-09-21 16:18:24 -0700 | [diff] [blame] | 44 | // Persists profile information, as well as that of discovered devices |
| 45 | // and bound services, to disk. |
| 46 | // Returns true on success, false on failure. |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 47 | virtual bool Save(); |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 48 | |
Darin Petkov | e7c6ad3 | 2012-06-29 10:22:09 +0200 | [diff] [blame] | 49 | // Inherited from Profile. |
| 50 | virtual bool UpdateDevice(const DeviceRefPtr &device); |
| 51 | |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 52 | protected: |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 53 | // Sets |path| to the persistent store file path for the default, global |
| 54 | // profile. Returns true on success, and false if unable to determine an |
| 55 | // appropriate file location. |
| 56 | // |
| 57 | // In this implementation, |name_| is ignored. |
| 58 | virtual bool GetStoragePath(FilePath *path); |
| 59 | |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 60 | private: |
Paul Stewart | 870523b | 2012-01-11 17:00:42 -0800 | [diff] [blame] | 61 | friend class DefaultProfileTest; |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 62 | FRIEND_TEST(DefaultProfileTest, GetStoragePath); |
Paul Stewart | e692740 | 2012-01-23 16:11:30 -0800 | [diff] [blame] | 63 | FRIEND_TEST(DefaultProfileTest, LoadManagerDefaultProperties); |
Paul Stewart | 870523b | 2012-01-11 17:00:42 -0800 | [diff] [blame] | 64 | FRIEND_TEST(DefaultProfileTest, LoadManagerProperties); |
| 65 | FRIEND_TEST(DefaultProfileTest, Save); |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 66 | |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 67 | static const char kStorageId[]; |
Paul Stewart | d408fdf | 2012-05-07 17:15:57 -0700 | [diff] [blame] | 68 | static const char kStorageArpGateway[]; |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 69 | static const char kStorageCheckPortalList[]; |
Paul Stewart | d32f484 | 2012-01-11 16:08:13 -0800 | [diff] [blame] | 70 | static const char kStorageHostName[]; |
Paul Stewart | 4d5efb7 | 2012-09-17 12:24:34 -0700 | [diff] [blame] | 71 | static const char kStorageIgnoredDNSSearchPaths[]; |
Paul Stewart | 036dba0 | 2012-08-07 12:34:41 -0700 | [diff] [blame] | 72 | static const char kStorageLinkMonitorTechnologies[]; |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 73 | static const char kStorageName[]; |
| 74 | static const char kStorageOfflineMode[]; |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 75 | static const char kStoragePortalCheckInterval[]; |
Paul Stewart | e692740 | 2012-01-23 16:11:30 -0800 | [diff] [blame] | 76 | static const char kStoragePortalURL[]; |
Paul Stewart | bf66761 | 2012-06-29 14:49:54 -0700 | [diff] [blame] | 77 | static const char kStorageShortDNSTimeoutTechnologies[]; |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 78 | |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 79 | const FilePath storage_path_; |
Paul Stewart | d0a3b81 | 2012-03-28 22:48:22 -0700 | [diff] [blame] | 80 | const std::string profile_id_; |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 81 | const Manager::Properties &props_; |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 82 | |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 83 | DISALLOW_COPY_AND_ASSIGN(DefaultProfile); |
| 84 | }; |
| 85 | |
| 86 | } // namespace shill |
| 87 | |
| 88 | #endif // SHILL_DEFAULT_PROFILE_ |