Home | History | Annotate | Download | only in update_manager
      1 //
      2 // Copyright (C) 2014 The Android Open Source Project
      3 //
      4 // Licensed under the Apache License, Version 2.0 (the "License");
      5 // you may not use this file except in compliance with the License.
      6 // You may obtain a copy of the License at
      7 //
      8 //      http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unless required by applicable law or agreed to in writing, software
     11 // distributed under the License is distributed on an "AS IS" BASIS,
     12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 // See the License for the specific language governing permissions and
     14 // limitations under the License.
     15 //
     16 
     17 #ifndef UPDATE_ENGINE_UPDATE_MANAGER_REAL_STATE_H_
     18 #define UPDATE_ENGINE_UPDATE_MANAGER_REAL_STATE_H_
     19 
     20 #include <memory>
     21 
     22 #include "update_engine/update_manager/state.h"
     23 
     24 namespace chromeos_update_manager {
     25 
     26 // State concrete implementation.
     27 class RealState : public State {
     28  public:
     29   ~RealState() override {}
     30 
     31   RealState(ConfigProvider* config_provider,
     32             DevicePolicyProvider* device_policy_provider,
     33             RandomProvider* random_provider,
     34             ShillProvider* shill_provider,
     35             SystemProvider* system_provider,
     36             TimeProvider* time_provider,
     37             UpdaterProvider* updater_provider) :
     38       config_provider_(config_provider),
     39       device_policy_provider_(device_policy_provider),
     40       random_provider_(random_provider),
     41       shill_provider_(shill_provider),
     42       system_provider_(system_provider),
     43       time_provider_(time_provider),
     44       updater_provider_(updater_provider) {}
     45 
     46   // These methods return the given provider.
     47   ConfigProvider* config_provider() override {
     48     return config_provider_.get();
     49   }
     50   DevicePolicyProvider* device_policy_provider() override {
     51     return device_policy_provider_.get();
     52   }
     53   RandomProvider* random_provider() override {
     54     return random_provider_.get();
     55   }
     56   ShillProvider* shill_provider() override {
     57     return shill_provider_.get();
     58   }
     59   SystemProvider* system_provider() override {
     60     return system_provider_.get();
     61   }
     62   TimeProvider* time_provider() override {
     63     return time_provider_.get();
     64   }
     65   UpdaterProvider* updater_provider() override {
     66     return updater_provider_.get();
     67   }
     68 
     69  private:
     70   // Instances of the providers.
     71   std::unique_ptr<ConfigProvider> config_provider_;
     72   std::unique_ptr<DevicePolicyProvider> device_policy_provider_;
     73   std::unique_ptr<RandomProvider> random_provider_;
     74   std::unique_ptr<ShillProvider> shill_provider_;
     75   std::unique_ptr<SystemProvider> system_provider_;
     76   std::unique_ptr<TimeProvider> time_provider_;
     77   std::unique_ptr<UpdaterProvider> updater_provider_;
     78 };
     79 
     80 }  // namespace chromeos_update_manager
     81 
     82 #endif  // UPDATE_ENGINE_UPDATE_MANAGER_REAL_STATE_H_
     83