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

Side by Side Diff: content/test/weburl_loader_mock_factory.h

Issue 1743783002: Use WeakPtr and do not use pointer equality in WebURLLoaderMockFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Loader_URLTestHelpers
Patch Set: Rebase. Created 4 years, 9 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
« no previous file with comments | « content/test/weburl_loader_mock.cc ('k') | content/test/weburl_loader_mock_factory.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CONTENT_TEST_WEBURL_LOADER_MOCK_FACTORY_H_ 5 #ifndef CONTENT_TEST_WEBURL_LOADER_MOCK_FACTORY_H_
6 #define CONTENT_TEST_WEBURL_LOADER_MOCK_FACTORY_H_ 6 #define CONTENT_TEST_WEBURL_LOADER_MOCK_FACTORY_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
12 #include "third_party/WebKit/public/platform/WebURL.h" 13 #include "third_party/WebKit/public/platform/WebURL.h"
13 #include "third_party/WebKit/public/platform/WebURLError.h" 14 #include "third_party/WebKit/public/platform/WebURLError.h"
14 #include "third_party/WebKit/public/platform/WebURLRequest.h" 15 #include "third_party/WebKit/public/platform/WebURLRequest.h"
15 #include "third_party/WebKit/public/platform/WebURLResponse.h" 16 #include "third_party/WebKit/public/platform/WebURLResponse.h"
16 17
17 namespace blink { 18 namespace blink {
18 class WebData; 19 class WebData;
19 class WebURLLoader; 20 class WebURLLoader;
20 class WebURLLoaderTestDelegate; 21 class WebURLLoaderTestDelegate;
21 } 22 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 89
89 90
90 // Loads the specified request and populates the response, error and data 91 // Loads the specified request and populates the response, error and data
91 // accordingly. 92 // accordingly.
92 void LoadRequest(const blink::WebURLRequest& request, 93 void LoadRequest(const blink::WebURLRequest& request,
93 blink::WebURLResponse* response, 94 blink::WebURLResponse* response,
94 blink::WebURLError* error, 95 blink::WebURLError* error,
95 blink::WebData* data); 96 blink::WebData* data);
96 97
97 // Checks if the loader is pending. Otherwise, it may have been deleted. 98 // Checks if the loader is pending. Otherwise, it may have been deleted.
98 bool IsPending(WebURLLoaderMock* loader); 99 bool IsPending(base::WeakPtr<WebURLLoaderMock> loader);
99 100
100 // Reads |m_filePath| and puts its content in |data|. 101 // Reads |m_filePath| and puts its content in |data|.
101 // Returns true if it successfully read the file. 102 // Returns true if it successfully read the file.
102 static bool ReadFile(const base::FilePath& file_path, blink::WebData* data); 103 static bool ReadFile(const base::FilePath& file_path, blink::WebData* data);
103 104
104 blink::WebURLLoaderTestDelegate* delegate_; 105 blink::WebURLLoaderTestDelegate* delegate_;
105 106
106 // The loaders that have not being served data yet. 107 // The loaders that have not being served data yet.
107 typedef std::map<WebURLLoaderMock*, blink::WebURLRequest> LoaderToRequestMap; 108 typedef std::map<WebURLLoaderMock*, blink::WebURLRequest> LoaderToRequestMap;
108 LoaderToRequestMap pending_loaders_; 109 LoaderToRequestMap pending_loaders_;
109 110
110 typedef std::map<GURL, blink::WebURLError> URLToErrorMap; 111 typedef std::map<GURL, blink::WebURLError> URLToErrorMap;
111 URLToErrorMap url_to_error_info_; 112 URLToErrorMap url_to_error_info_;
112 113
113 // Table of the registered URLs and the responses that they should receive. 114 // Table of the registered URLs and the responses that they should receive.
114 typedef std::map<GURL, ResponseInfo> URLToResponseMap; 115 typedef std::map<GURL, ResponseInfo> URLToResponseMap;
115 URLToResponseMap url_to_reponse_info_; 116 URLToResponseMap url_to_reponse_info_;
116 117
117 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderMockFactory); 118 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderMockFactory);
118 }; 119 };
119 120
120 #endif // CONTENT_TEST_WEBURL_LOADER_MOCK_FACTORY_H_ 121 #endif // CONTENT_TEST_WEBURL_LOADER_MOCK_FACTORY_H_
121 122
OLDNEW
« no previous file with comments | « content/test/weburl_loader_mock.cc ('k') | content/test/weburl_loader_mock_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698