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

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

Issue 2822453003: Wrap large IndexedDB values into Blobs before writing to LevelDB. (Closed)
Patch Set: Addressed last round of feedback. Created 3 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 WebURLLoaderMockFactoryImpl_h 5 #ifndef WebURLLoaderMockFactoryImpl_h
6 #define WebURLLoaderMockFactoryImpl_h 6 #define WebURLLoaderMockFactoryImpl_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"
(...skipping 27 matching lines...) Expand all
38 // WebURLLoaderMockFactory: 38 // WebURLLoaderMockFactory:
39 std::unique_ptr<WebURLLoader> CreateURLLoader( 39 std::unique_ptr<WebURLLoader> CreateURLLoader(
40 std::unique_ptr<WebURLLoader> default_loader) override; 40 std::unique_ptr<WebURLLoader> default_loader) override;
41 void RegisterURL(const WebURL& url, 41 void RegisterURL(const WebURL& url,
42 const WebURLResponse& response, 42 const WebURLResponse& response,
43 const WebString& file_path = WebString()) override; 43 const WebString& file_path = WebString()) override;
44 void RegisterErrorURL(const WebURL& url, 44 void RegisterErrorURL(const WebURL& url,
45 const WebURLResponse& response, 45 const WebURLResponse& response,
46 const WebURLError& error) override; 46 const WebURLError& error) override;
47 void UnregisterURL(const WebURL& url) override; 47 void UnregisterURL(const WebURL& url) override;
48 void RegisterURLProtocol(const WebString& protocol,
49 const WebURLResponse& response,
50 const WebString& file_path) override;
51 void UnregisterURLProtocol(const WebString& protocol) override;
48 void UnregisterAllURLsAndClearMemoryCache() override; 52 void UnregisterAllURLsAndClearMemoryCache() override;
49 void ServeAsynchronousRequests() override; 53 void ServeAsynchronousRequests() override;
50 void SetLoaderDelegate(WebURLLoaderTestDelegate* delegate) override { 54 void SetLoaderDelegate(WebURLLoaderTestDelegate* delegate) override {
51 delegate_ = delegate; 55 delegate_ = delegate;
52 } 56 }
53 57
54 // Returns true if |url| was registered for being mocked. 58 // Returns true if |url| was registered for being mocked.
55 bool IsMockedURL(const WebURL& url); 59 bool IsMockedURL(const WebURL& url);
56 60
57 // Called by the loader to load a resource. 61 // Called by the loader to load a resource.
(...skipping 19 matching lines...) Expand all
77 // Loads the specified request and populates the response, error and data 81 // Loads the specified request and populates the response, error and data
78 // accordingly. 82 // accordingly.
79 void LoadRequest(const WebURLRequest& request, 83 void LoadRequest(const WebURLRequest& request,
80 WebURLResponse* response, 84 WebURLResponse* response,
81 WebURLError* error, 85 WebURLError* error,
82 WebData* data); 86 WebData* data);
83 87
84 // Checks if the loader is pending. Otherwise, it may have been deleted. 88 // Checks if the loader is pending. Otherwise, it may have been deleted.
85 bool IsPending(WeakPtr<WebURLLoaderMock> loader); 89 bool IsPending(WeakPtr<WebURLLoaderMock> loader);
86 90
91 // Looks up an URL in the mock URL table.
92 //
93 // If the URL is found, returns true and sets |error| and |response_info|.
94 bool LookupURL(const WebURL& url,
95 WebURLError* error,
96 ResponseInfo* response_info);
97
87 // Reads |m_filePath| and puts its content in |data|. 98 // Reads |m_filePath| and puts its content in |data|.
88 // Returns true if it successfully read the file. 99 // Returns true if it successfully read the file.
89 static bool ReadFile(const base::FilePath& file_path, WebData* data); 100 static bool ReadFile(const base::FilePath& file_path, WebData* data);
90 101
91 WebURLLoaderTestDelegate* delegate_ = nullptr; 102 WebURLLoaderTestDelegate* delegate_ = nullptr;
92 103
93 // The loaders that have not being served data yet. 104 // The loaders that have not being served data yet.
94 using LoaderToRequestMap = HashMap<WebURLLoaderMock*, WebURLRequest>; 105 using LoaderToRequestMap = HashMap<WebURLLoaderMock*, WebURLRequest>;
95 LoaderToRequestMap pending_loaders_; 106 LoaderToRequestMap pending_loaders_;
96 107
97 typedef HashMap<KURL, WebURLError> URLToErrorMap; 108 typedef HashMap<KURL, WebURLError> URLToErrorMap;
98 URLToErrorMap url_to_error_info_; 109 URLToErrorMap url_to_error_info_;
99 110
100 // Table of the registered URLs and the responses that they should receive. 111 // Table of the registered URLs and the responses that they should receive.
101 using URLToResponseMap = HashMap<KURL, ResponseInfo>; 112 using URLToResponseMap = HashMap<KURL, ResponseInfo>;
102 URLToResponseMap url_to_response_info_; 113 URLToResponseMap url_to_response_info_;
103 114
115 // Table of the registered URL protocols and the responses that they should
116 // receive.
117 using ProtocolToResponseMap = HashMap<String, ResponseInfo>;
118 ProtocolToResponseMap protocol_to_response_info_;
119
104 TestingPlatformSupport* platform_; 120 TestingPlatformSupport* platform_;
105 121
106 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderMockFactoryImpl); 122 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderMockFactoryImpl);
107 }; 123 };
108 124
109 } // namespace blink 125 } // namespace blink
110 126
111 #endif // WebURLLoaderMockFactoryImpl_h 127 #endif // WebURLLoaderMockFactoryImpl_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698