Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h

Issue 1456873003: More regular Platform implementations in unit tests (reland.) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: have GN disable c4267 also Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef TestingPlatformSupport_h 31 #ifndef TestingPlatformSupport_h
32 #define TestingPlatformSupport_h 32 #define TestingPlatformSupport_h
33 33
34 #include "platform/PlatformExport.h"
34 #include "public/platform/Platform.h" 35 #include "public/platform/Platform.h"
35 #include "public/platform/WebDiscardableMemory.h" 36 #include "public/platform/WebDiscardableMemory.h"
36 #include "wtf/Vector.h" 37 #include "wtf/Vector.h"
37 38
38 namespace blink { 39 namespace blink {
39 40
41 class WebCompositorSupport;
42 class WebThread;
43
40 class TestingDiscardableMemory : public WebDiscardableMemory { 44 class TestingDiscardableMemory : public WebDiscardableMemory {
41 public: 45 public:
42 explicit TestingDiscardableMemory(size_t); 46 explicit TestingDiscardableMemory(size_t);
43 ~TestingDiscardableMemory() override; 47 ~TestingDiscardableMemory() override;
44 48
45 // WebDiscardableMemory: 49 // WebDiscardableMemory:
46 bool lock() override; 50 bool lock() override;
47 void* data() override; 51 void* data() override;
48 void unlock() override; 52 void unlock() override;
49 WebMemoryAllocatorDump* createMemoryAllocatorDump(const WebString& name, Web ProcessMemoryDump*) const override; 53 WebMemoryAllocatorDump* createMemoryAllocatorDump(const WebString& name, Web ProcessMemoryDump*) const override;
50 54
51 private: 55 private:
52 Vector<char> m_data; 56 Vector<char> m_data;
53 bool m_isLocked; 57 bool m_isLocked;
54 }; 58 };
55 59
56 class TestingPlatformSupport : public Platform { 60 class TestingPlatformSupport : public Platform {
57 public: 61 public:
58 struct Config { 62 struct Config {
59 Config() 63 Config()
60 : hasDiscardableMemorySupport(false) 64 : hasDiscardableMemorySupport(false)
61 , compositorSupport(nullptr) { } 65 , compositorSupport(nullptr) { }
62 66
63 bool hasDiscardableMemorySupport; 67 bool hasDiscardableMemorySupport;
64 WebCompositorSupport* compositorSupport; 68 WebCompositorSupport* compositorSupport;
65 }; 69 };
66 70
71 TestingPlatformSupport();
67 explicit TestingPlatformSupport(const Config&); 72 explicit TestingPlatformSupport(const Config&);
68 73
69 ~TestingPlatformSupport() override; 74 ~TestingPlatformSupport() override;
70 75
71 // Platform: 76 // Platform:
72 WebDiscardableMemory* allocateAndLockDiscardableMemory(size_t bytes) overrid e; 77 WebDiscardableMemory* allocateAndLockDiscardableMemory(size_t bytes) overrid e;
73 void cryptographicallyRandomValues(unsigned char* buffer, size_t length) ove rride; 78 void cryptographicallyRandomValues(unsigned char* buffer, size_t length) ove rride;
74 const unsigned char* getTraceCategoryEnabledFlag(const char* categoryName) o verride; 79 const unsigned char* getTraceCategoryEnabledFlag(const char* categoryName) o verride;
75 WebString defaultLocale() override; 80 WebString defaultLocale() override;
76 WebCompositorSupport* compositorSupport() override; 81 WebCompositorSupport* compositorSupport() override;
82 WebThread* currentThread() override;
77 83
78 private: 84 protected:
79 const Config m_config; 85 const Config m_config;
80 Platform* const m_oldPlatform; 86 Platform* const m_oldPlatform;
81 }; 87 };
82 88
83 } // namespace blink 89 } // namespace blink
84 90
85 #endif // TestingPlatformSupport_h 91 #endif // TestingPlatformSupport_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698