OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_INSTALL_STATIC_TEST_SCOPED_INSTALL_DETAILS_H_ | 5 #ifndef CHROME_INSTALL_STATIC_TEST_SCOPED_INSTALL_DETAILS_H_ |
6 #define CHROME_INSTALL_STATIC_TEST_SCOPED_INSTALL_DETAILS_H_ | 6 #define CHROME_INSTALL_STATIC_TEST_SCOPED_INSTALL_DETAILS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 | 11 |
12 namespace install_static { | 12 namespace install_static { |
13 | 13 |
14 class InstallDetails; | 14 class InstallDetails; |
15 | 15 |
16 // A facility for tests to register an InstallDetails for the duration of a | 16 // A facility for tests to register an InstallDetails for the duration of a |
17 // test harness or test run. | 17 // test harness or test run. |
18 class ScopedInstallDetails { | 18 class ScopedInstallDetails { |
19 public: | 19 public: |
20 // Installs an InstallDetails instance that will report the install as being | 20 // Installs an InstallDetails instance that will report the install as being |
21 // at |system_level| and of mode |install_mode_index| (an InstallConstantIndex | 21 // at |system_level| and of mode |install_mode_index| (an InstallConstantIndex |
22 // value) of the current brand; see ../install_modes.h for details. | 22 // value) of the current brand; see ../install_modes.h for details. |
| 23 // TODO(grt): replace bool and int with more obvious types (e.g., enum). |
23 explicit ScopedInstallDetails(bool system_level = false, | 24 explicit ScopedInstallDetails(bool system_level = false, |
24 int install_mode_index = 0); | 25 int install_mode_index = 0); |
25 ~ScopedInstallDetails(); | 26 ~ScopedInstallDetails(); |
26 | 27 |
27 private: | 28 private: |
28 // A raw pointer to the InstallDetails instance created by this object. This | 29 // A raw pointer to the InstallDetails instance created by this object. This |
29 // is used only to assert that no intervening instances were swapped in yet | 30 // is used only to assert that no intervening instances were swapped in yet |
30 // not restored during the lifetime of this object. | 31 // not restored during the lifetime of this object. |
31 const InstallDetails* these_details_ = nullptr; | 32 const InstallDetails* these_details_ = nullptr; |
32 | 33 |
33 // The module's InstallDetails instance prior to the creation of this object. | 34 // The module's InstallDetails instance prior to the creation of this object. |
34 // This instance will be swapped back into place when this object is | 35 // This instance will be swapped back into place when this object is |
35 // destroyed. | 36 // destroyed. |
36 std::unique_ptr<const InstallDetails> previous_details_; | 37 std::unique_ptr<const InstallDetails> previous_details_; |
37 | 38 |
38 DISALLOW_COPY_AND_ASSIGN(ScopedInstallDetails); | 39 DISALLOW_COPY_AND_ASSIGN(ScopedInstallDetails); |
39 }; | 40 }; |
40 | 41 |
41 } // namespace install_static | 42 } // namespace install_static |
42 | 43 |
43 #endif // CHROME_INSTALL_STATIC_TEST_SCOPED_INSTALL_DETAILS_H_ | 44 #endif // CHROME_INSTALL_STATIC_TEST_SCOPED_INSTALL_DETAILS_H_ |
OLD | NEW |