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

Side by Side Diff: third_party/WebKit/Source/web/tests/sim/SimNetwork.cpp

Issue 2683033005: URLLoaderMockFactory: clear MemoryCache in unregisterAllURLs (Closed)
Patch Set: fix Created 3 years, 10 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
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 "web/tests/sim/SimNetwork.h" 5 #include "web/tests/sim/SimNetwork.h"
6 6
7 #include "public/platform/Platform.h" 7 #include "public/platform/Platform.h"
8 #include "public/platform/WebURLError.h" 8 #include "public/platform/WebURLError.h"
9 #include "public/platform/WebURLLoader.h" 9 #include "public/platform/WebURLLoader.h"
10 #include "public/platform/WebURLLoaderClient.h" 10 #include "public/platform/WebURLLoaderClient.h"
11 #include "public/platform/WebURLLoaderMockFactory.h" 11 #include "public/platform/WebURLLoaderMockFactory.h"
12 #include "public/platform/WebURLResponse.h" 12 #include "public/platform/WebURLResponse.h"
13 #include "web/tests/sim/SimRequest.h" 13 #include "web/tests/sim/SimRequest.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 static SimNetwork* s_network = nullptr; 17 static SimNetwork* s_network = nullptr;
18 18
19 SimNetwork::SimNetwork() : m_currentRequest(nullptr) { 19 SimNetwork::SimNetwork() : m_currentRequest(nullptr) {
20 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(this); 20 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(this);
21 ASSERT(!s_network); 21 ASSERT(!s_network);
22 s_network = this; 22 s_network = this;
23 } 23 }
24 24
25 SimNetwork::~SimNetwork() { 25 SimNetwork::~SimNetwork() {
26 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); 26 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr);
27 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 27 Platform::current()
28 ->getURLLoaderMockFactory()
29 ->unregisterAllURLsAndClearMemoryCache();
28 s_network = nullptr; 30 s_network = nullptr;
29 } 31 }
30 32
31 SimNetwork& SimNetwork::current() { 33 SimNetwork& SimNetwork::current() {
32 DCHECK(s_network); 34 DCHECK(s_network);
33 return *s_network; 35 return *s_network;
34 } 36 }
35 37
36 void SimNetwork::servePendingRequests() { 38 void SimNetwork::servePendingRequests() {
37 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); 39 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 83
82 void SimNetwork::addRequest(SimRequest& request) { 84 void SimNetwork::addRequest(SimRequest& request) {
83 m_requests.insert(request.url(), &request); 85 m_requests.insert(request.url(), &request);
84 } 86 }
85 87
86 void SimNetwork::removeRequest(SimRequest& request) { 88 void SimNetwork::removeRequest(SimRequest& request) {
87 m_requests.erase(request.url()); 89 m_requests.erase(request.url());
88 } 90 }
89 91
90 } // namespace blink 92 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebViewTest.cpp ('k') | third_party/WebKit/public/platform/WebURLLoaderMockFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698