| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // Arg arg; | 187 // Arg arg; |
| 188 // ScopedTestingPlatformSupport<MyAnotherTestingPlatformSupport, const Arg&> | 188 // ScopedTestingPlatformSupport<MyAnotherTestingPlatformSupport, const Arg&> |
| 189 // another_platform(args); | 189 // another_platform(args); |
| 190 // ... | 190 // ... |
| 191 // } | 191 // } |
| 192 // | 192 // |
| 193 // // Here the original MyTestingPlatformSupport should be restored. | 193 // // Here the original MyTestingPlatformSupport should be restored. |
| 194 // } | 194 // } |
| 195 template <class T, typename... Args> | 195 template <class T, typename... Args> |
| 196 class ScopedTestingPlatformSupport final { | 196 class ScopedTestingPlatformSupport final { |
| 197 STACK_ALLOCATED(); | 197 WTF_MAKE_NONCOPYABLE(ScopedTestingPlatformSupport); |
| 198 | 198 |
| 199 public: | 199 public: |
| 200 explicit ScopedTestingPlatformSupport(Args&&... args) { | 200 explicit ScopedTestingPlatformSupport(Args&&... args) { |
| 201 m_testingPlatformSupport = WTF::makeUnique<T>(std::forward<Args>(args)...); | 201 m_testingPlatformSupport = WTF::makeUnique<T>(std::forward<Args>(args)...); |
| 202 m_originalPlatform = Platform::current(); | 202 m_originalPlatform = Platform::current(); |
| 203 DCHECK(m_originalPlatform); | 203 DCHECK(m_originalPlatform); |
| 204 Platform::setCurrentPlatformForTesting(m_testingPlatformSupport.get()); | 204 Platform::setCurrentPlatformForTesting(m_testingPlatformSupport.get()); |
| 205 } | 205 } |
| 206 ~ScopedTestingPlatformSupport() { | 206 ~ScopedTestingPlatformSupport() { |
| 207 DCHECK_EQ(m_testingPlatformSupport.get(), Platform::current()); | 207 DCHECK_EQ(m_testingPlatformSupport.get(), Platform::current()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 230 m_discardableMemoryAllocator; | 230 m_discardableMemoryAllocator; |
| 231 std::unique_ptr<DummyPlatform> m_dummyPlatform; | 231 std::unique_ptr<DummyPlatform> m_dummyPlatform; |
| 232 std::unique_ptr<cc_blink::WebCompositorSupportImpl> m_compositorSupport; | 232 std::unique_ptr<cc_blink::WebCompositorSupportImpl> m_compositorSupport; |
| 233 TestingPlatformSupport::Config m_testingPlatformConfig; | 233 TestingPlatformSupport::Config m_testingPlatformConfig; |
| 234 std::unique_ptr<TestingPlatformSupport> m_testingPlatformSupport; | 234 std::unique_ptr<TestingPlatformSupport> m_testingPlatformSupport; |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 } // namespace blink | 237 } // namespace blink |
| 238 | 238 |
| 239 #endif // TestingPlatformSupport_h | 239 #endif // TestingPlatformSupport_h |
| OLD | NEW |