blob: 084aab7dbb3b3578af2719f3838cb2d1113ce9df [file] [log] [blame]
Utkarsh Sanghibbef5df2015-09-09 19:34:06 -07001//
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 Krahn03d54df2014-10-14 17:36:54 -070016
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 Krahnef87f3e2015-03-10 19:38:31 -070026
Vadim Bendeburyc7a43d62015-06-10 16:11:47 -070027#include "trunks/command_transceiver.h"
Darren Krahnef87f3e2015-03-10 19:38:31 -070028#include "trunks/trunks_export.h"
Darren Krahn03d54df2014-10-14 17:36:54 -070029
30namespace trunks {
31
32class Tpm;
33class TrunksProxy;
34
35// TrunksFactoryImpl is the default TrunksFactory implementation.
Darren Krahnef87f3e2015-03-10 19:38:31 -070036class TRUNKS_EXPORT TrunksFactoryImpl : public TrunksFactory {
Darren Krahn03d54df2014-10-14 17:36:54 -070037 public:
Utkarsh Sanghide165992015-06-29 14:32:49 -070038 // 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 Krahn617ff7c2015-03-16 11:11:50 -070044 ~TrunksFactoryImpl() override;
Darren Krahn03d54df2014-10-14 17:36:54 -070045
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 Sanghiff7f2da2015-04-13 10:15:24 -070052 scoped_ptr<SessionManager> GetSessionManager() const override;
53 scoped_ptr<HmacSession> GetHmacSession() const override;
54 scoped_ptr<PolicySession> GetPolicySession() const override;
Utkarsh Sanghibe411152015-05-15 14:16:19 -070055 scoped_ptr<PolicySession> GetTrialSession() const override;
Utkarsh Sanghi0ebbc582015-07-16 11:01:03 -070056 scoped_ptr<BlobParser> GetBlobParser() const override;
Darren Krahn03d54df2014-10-14 17:36:54 -070057
58 private:
Utkarsh Sanghide165992015-06-29 14:32:49 -070059 scoped_ptr<CommandTransceiver> default_transceiver_;
60 CommandTransceiver* transceiver_;
61 scoped_ptr<Tpm> tpm_;
Darren Krahn03d54df2014-10-14 17:36:54 -070062
63 DISALLOW_COPY_AND_ASSIGN(TrunksFactoryImpl);
64};
65
66} // namespace trunks
67
68#endif // TRUNKS_TRUNKS_FACTORY_IMPL_H_