Utkarsh Sanghi | bbef5df | 2015-09-09 19:34:06 -0700 | [diff] [blame] | 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 | // |
Darren Krahn | 03d54df | 2014-10-14 17:36:54 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef TRUNKS_TRUNKS_FACTORY_IMPL_H_ |
| 18 | #define TRUNKS_TRUNKS_FACTORY_IMPL_H_ |
| 19 | |
| 20 | #include "trunks/trunks_factory.h" |
| 21 | |
| 22 | #include <string> |
| 23 | |
| 24 | #include <base/macros.h> |
| 25 | #include <base/memory/scoped_ptr.h> |
Darren Krahn | ef87f3e | 2015-03-10 19:38:31 -0700 | [diff] [blame] | 26 | |
Vadim Bendebury | c7a43d6 | 2015-06-10 16:11:47 -0700 | [diff] [blame] | 27 | #include "trunks/command_transceiver.h" |
Darren Krahn | ef87f3e | 2015-03-10 19:38:31 -0700 | [diff] [blame] | 28 | #include "trunks/trunks_export.h" |
Darren Krahn | 03d54df | 2014-10-14 17:36:54 -0700 | [diff] [blame] | 29 | |
| 30 | namespace trunks { |
| 31 | |
| 32 | class Tpm; |
| 33 | class TrunksProxy; |
| 34 | |
| 35 | // TrunksFactoryImpl is the default TrunksFactory implementation. |
Darren Krahn | ef87f3e | 2015-03-10 19:38:31 -0700 | [diff] [blame] | 36 | class TRUNKS_EXPORT TrunksFactoryImpl : public TrunksFactory { |
Darren Krahn | 03d54df | 2014-10-14 17:36:54 -0700 | [diff] [blame] | 37 | public: |
Utkarsh Sanghi | de16599 | 2015-06-29 14:32:49 -0700 | [diff] [blame] | 38 | // Uses TrunksProxy as the default CommandTransceiver to pass to the TPM. |
| 39 | TrunksFactoryImpl(); |
| 40 | // TrunksFactoryImpl does not take ownership of |transceiver|. This |
| 41 | // transceiver is forwarded down to the Tpm instance maintained by |
| 42 | // this factory. |
| 43 | explicit TrunksFactoryImpl(CommandTransceiver* transceiver); |
Darren Krahn | 617ff7c | 2015-03-16 11:11:50 -0700 | [diff] [blame] | 44 | ~TrunksFactoryImpl() override; |
Darren Krahn | 03d54df | 2014-10-14 17:36:54 -0700 | [diff] [blame] | 45 | |
| 46 | // TrunksFactory methods. |
| 47 | Tpm* GetTpm() const override; |
| 48 | scoped_ptr<TpmState> GetTpmState() const override; |
| 49 | scoped_ptr<TpmUtility> GetTpmUtility() const override; |
| 50 | scoped_ptr<AuthorizationDelegate> GetPasswordAuthorization( |
| 51 | const std::string& password) const override; |
Utkarsh Sanghi | ff7f2da | 2015-04-13 10:15:24 -0700 | [diff] [blame] | 52 | scoped_ptr<SessionManager> GetSessionManager() const override; |
| 53 | scoped_ptr<HmacSession> GetHmacSession() const override; |
| 54 | scoped_ptr<PolicySession> GetPolicySession() const override; |
Utkarsh Sanghi | be41115 | 2015-05-15 14:16:19 -0700 | [diff] [blame] | 55 | scoped_ptr<PolicySession> GetTrialSession() const override; |
Utkarsh Sanghi | 0ebbc58 | 2015-07-16 11:01:03 -0700 | [diff] [blame] | 56 | scoped_ptr<BlobParser> GetBlobParser() const override; |
Darren Krahn | 03d54df | 2014-10-14 17:36:54 -0700 | [diff] [blame] | 57 | |
| 58 | private: |
Utkarsh Sanghi | de16599 | 2015-06-29 14:32:49 -0700 | [diff] [blame] | 59 | scoped_ptr<CommandTransceiver> default_transceiver_; |
| 60 | CommandTransceiver* transceiver_; |
| 61 | scoped_ptr<Tpm> tpm_; |
Darren Krahn | 03d54df | 2014-10-14 17:36:54 -0700 | [diff] [blame] | 62 | |
| 63 | DISALLOW_COPY_AND_ASSIGN(TrunksFactoryImpl); |
| 64 | }; |
| 65 | |
| 66 | } // namespace trunks |
| 67 | |
| 68 | #endif // TRUNKS_TRUNKS_FACTORY_IMPL_H_ |