OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_ | 5 #ifndef WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_ |
6 #define WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_ | 6 #define WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 private: | 69 private: |
70 struct ResponseInfo; | 70 struct ResponseInfo; |
71 | 71 |
72 // Loads the specified request and populates the response, error and data | 72 // Loads the specified request and populates the response, error and data |
73 // accordingly. | 73 // accordingly. |
74 void LoadRequest(const WebKit::WebURLRequest& request, | 74 void LoadRequest(const WebKit::WebURLRequest& request, |
75 WebKit::WebURLResponse* response, | 75 WebKit::WebURLResponse* response, |
76 WebKit::WebURLError* error, | 76 WebKit::WebURLError* error, |
77 WebKit::WebData* data); | 77 WebKit::WebData* data); |
78 | 78 |
| 79 // Checks if the loader is pending. Otherwise, it may have been deleted. |
| 80 bool IsPending(WebURLLoaderMock* loader); |
| 81 |
79 // Reads |m_filePath| and puts its content in |data|. | 82 // Reads |m_filePath| and puts its content in |data|. |
80 // Returns true if it successfully read the file. | 83 // Returns true if it successfully read the file. |
81 static bool ReadFile(const FilePath& file_path, WebKit::WebData* data); | 84 static bool ReadFile(const FilePath& file_path, WebKit::WebData* data); |
82 | 85 |
83 // The loaders that have not being served data yet. | 86 // The loaders that have not being served data yet. |
84 typedef std::map<WebURLLoaderMock*, WebKit::WebURLRequest> LoaderToRequestMap; | 87 typedef std::map<WebURLLoaderMock*, WebKit::WebURLRequest> LoaderToRequestMap; |
85 LoaderToRequestMap pending_loaders_; | 88 LoaderToRequestMap pending_loaders_; |
86 | 89 |
87 // Table of the registered URLs and the responses that they should receive. | 90 // Table of the registered URLs and the responses that they should receive. |
88 typedef std::map<WebKit::WebURL, ResponseInfo> URLToResponseMap; | 91 typedef std::map<WebKit::WebURL, ResponseInfo> URLToResponseMap; |
89 URLToResponseMap url_to_reponse_info_; | 92 URLToResponseMap url_to_reponse_info_; |
90 | 93 |
91 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderMockFactory); | 94 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderMockFactory); |
92 }; | 95 }; |
93 | 96 |
94 #endif // WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_ | 97 #endif // WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_ |
95 | 98 |
OLD | NEW |