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

Side by Side Diff: Source/core/fetch/ResourceTest.cpp

Issue 1151633004: Revert of Implement timers by posting delayed tasks (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/fetch/CachingCorrectnessTest.cpp ('k') | Source/core/frame/DOMTimerCoordinator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "config.h" 5 #include "config.h"
6 #include "core/fetch/Resource.h" 6 #include "core/fetch/Resource.h"
7 7
8 #include "core/fetch/ResourcePtr.h" 8 #include "core/fetch/ResourcePtr.h"
9 #include "platform/network/ResourceRequest.h" 9 #include "platform/network/ResourceRequest.h"
10 #include "platform/network/ResourceResponse.h" 10 #include "platform/network/ResourceResponse.h"
11 #include "platform/testing/URLTestHelpers.h" 11 #include "platform/testing/URLTestHelpers.h"
12 #include "public/platform/Platform.h" 12 #include "public/platform/Platform.h"
13 #include "wtf/Vector.h" 13 #include "wtf/Vector.h"
14 14
15 #include <gtest/gtest.h> 15 #include <gtest/gtest.h>
16 16
17 using namespace blink; 17 using namespace blink;
18 18
19 namespace blink { 19 namespace blink {
20 20
21 namespace { 21 namespace {
22 22
23 class MockPlatform final : public Platform { 23 class MockPlatform final : public Platform {
24 public: 24 public:
25 MockPlatform() : m_oldPlatform(Platform::current()) { } 25 MockPlatform() { }
26 ~MockPlatform() override { } 26 ~MockPlatform() override { }
27 27
28 // From blink::Platform: 28 // From blink::Platform:
29 void cacheMetadata(const WebURL& url, int64, const char*, size_t) override 29 void cacheMetadata(const WebURL& url, int64, const char*, size_t) override
30 { 30 {
31 m_cachedURLs.append(url); 31 m_cachedURLs.append(url);
32 } 32 }
33 void cryptographicallyRandomValues(unsigned char* buffer, size_t length) ove rride 33 void cryptographicallyRandomValues(unsigned char* buffer, size_t length) ove rride
34 { 34 {
35 ASSERT_NOT_REACHED(); 35 ASSERT_NOT_REACHED();
36 } 36 }
37 37
38 const Vector<WebURL>& cachedURLs() const 38 const Vector<WebURL>& cachedURLs() const
39 { 39 {
40 return m_cachedURLs; 40 return m_cachedURLs;
41 } 41 }
42 42
43 WebThread* currentThread() override
44 {
45 return m_oldPlatform->currentThread();
46 }
47
48 private: 43 private:
49 Platform* m_oldPlatform; // Not owned.
50 Vector<WebURL> m_cachedURLs; 44 Vector<WebURL> m_cachedURLs;
51 }; 45 };
52 46
53 class AutoInstallMockPlatform { 47 class AutoInstallMockPlatform {
54 public: 48 public:
55 AutoInstallMockPlatform() 49 AutoInstallMockPlatform()
56 { 50 {
57 m_oldPlatform = Platform::current(); 51 m_oldPlatform = Platform::current();
58 Platform::initialize(&m_mockPlatform); 52 Platform::initialize(&m_mockPlatform);
59 } 53 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 TEST(ResourceTest, SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedVia ServiceWorker) 91 TEST(ResourceTest, SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedVia ServiceWorker)
98 { 92 {
99 AutoInstallMockPlatform mock; 93 AutoInstallMockPlatform mock;
100 OwnPtr<ResourceResponse> response(createTestResourceResponse()); 94 OwnPtr<ResourceResponse> response(createTestResourceResponse());
101 response->setWasFetchedViaServiceWorker(true); 95 response->setWasFetchedViaServiceWorker(true);
102 createTestResourceAndSetCachedMetadata(response.get()); 96 createTestResourceAndSetCachedMetadata(response.get());
103 EXPECT_EQ(0u, mock.platform()->cachedURLs().size()); 97 EXPECT_EQ(0u, mock.platform()->cachedURLs().size());
104 } 98 }
105 99
106 } // namespace blink 100 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/fetch/CachingCorrectnessTest.cpp ('k') | Source/core/frame/DOMTimerCoordinator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698