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

Side by Side Diff: Source/modules/cachestorage/CacheTest.cpp

Issue 1155573003: CacheStorage: Pass an error object allocated on heap to WebCallbacks::onError (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix unittests Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "modules/cachestorage/Cache.h" 6 #include "modules/cachestorage/Cache.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptFunction.h" 9 #include "bindings/core/v8/ScriptFunction.h"
10 #include "bindings/core/v8/ScriptPromise.h" 10 #include "bindings/core/v8/ScriptPromise.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void setExpectedBatchOperations(const WebVector<BatchOperation>* expectedBat chOperations) { m_expectedBatchOperations = expectedBatchOperations; } 105 void setExpectedBatchOperations(const WebVector<BatchOperation>* expectedBat chOperations) { m_expectedBatchOperations = expectedBatchOperations; }
106 106
107 // From WebServiceWorkerCache: 107 // From WebServiceWorkerCache:
108 virtual void dispatchMatch(CacheMatchCallbacks* callbacks, const WebServiceW orkerRequest& webRequest, const QueryParams& queryParams) override 108 virtual void dispatchMatch(CacheMatchCallbacks* callbacks, const WebServiceW orkerRequest& webRequest, const QueryParams& queryParams) override
109 { 109 {
110 m_lastErrorWebCacheMethodCalled = "dispatchMatch"; 110 m_lastErrorWebCacheMethodCalled = "dispatchMatch";
111 checkUrlIfProvided(webRequest.url()); 111 checkUrlIfProvided(webRequest.url());
112 checkQueryParamsIfProvided(queryParams); 112 checkQueryParamsIfProvided(queryParams);
113 113
114 OwnPtr<CacheMatchCallbacks> ownedCallbacks(adoptPtr(callbacks)); 114 OwnPtr<CacheMatchCallbacks> ownedCallbacks(adoptPtr(callbacks));
115 WebServiceWorkerCacheError error = m_error; 115 return callbacks->onError(new WebServiceWorkerCacheError(m_error));
116 return callbacks->onError(&error);
117 } 116 }
118 117
119 virtual void dispatchMatchAll(CacheWithResponsesCallbacks* callbacks, const WebServiceWorkerRequest& webRequest, const QueryParams& queryParams) override 118 virtual void dispatchMatchAll(CacheWithResponsesCallbacks* callbacks, const WebServiceWorkerRequest& webRequest, const QueryParams& queryParams) override
120 { 119 {
121 m_lastErrorWebCacheMethodCalled = "dispatchMatchAll"; 120 m_lastErrorWebCacheMethodCalled = "dispatchMatchAll";
122 checkUrlIfProvided(webRequest.url()); 121 checkUrlIfProvided(webRequest.url());
123 checkQueryParamsIfProvided(queryParams); 122 checkQueryParamsIfProvided(queryParams);
124 123
125 OwnPtr<CacheWithResponsesCallbacks> ownedCallbacks(adoptPtr(callbacks)); 124 OwnPtr<CacheWithResponsesCallbacks> ownedCallbacks(adoptPtr(callbacks));
126 WebServiceWorkerCacheError error = m_error; 125 return callbacks->onError(new WebServiceWorkerCacheError(m_error));
127 return callbacks->onError(&error);
128 } 126 }
129 127
130 virtual void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebSe rviceWorkerRequest* webRequest, const QueryParams& queryParams) override 128 virtual void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebSe rviceWorkerRequest* webRequest, const QueryParams& queryParams) override
131 { 129 {
132 m_lastErrorWebCacheMethodCalled = "dispatchKeys"; 130 m_lastErrorWebCacheMethodCalled = "dispatchKeys";
133 if (webRequest) { 131 if (webRequest) {
134 checkUrlIfProvided(webRequest->url()); 132 checkUrlIfProvided(webRequest->url());
135 checkQueryParamsIfProvided(queryParams); 133 checkQueryParamsIfProvided(queryParams);
136 } 134 }
137 135
138 OwnPtr<CacheWithRequestsCallbacks> ownedCallbacks(adoptPtr(callbacks)); 136 OwnPtr<CacheWithRequestsCallbacks> ownedCallbacks(adoptPtr(callbacks));
139 WebServiceWorkerCacheError error = m_error; 137 return callbacks->onError(new WebServiceWorkerCacheError(m_error));
140 return callbacks->onError(&error);
141 } 138 }
142 139
143 virtual void dispatchBatch(CacheBatchCallbacks* callbacks, const WebVector<B atchOperation>& batchOperations) override 140 virtual void dispatchBatch(CacheBatchCallbacks* callbacks, const WebVector<B atchOperation>& batchOperations) override
144 { 141 {
145 m_lastErrorWebCacheMethodCalled = "dispatchBatch"; 142 m_lastErrorWebCacheMethodCalled = "dispatchBatch";
146 checkBatchOperationsIfProvided(batchOperations); 143 checkBatchOperationsIfProvided(batchOperations);
147 144
148 OwnPtr<CacheBatchCallbacks> ownedCallbacks(adoptPtr(callbacks)); 145 OwnPtr<CacheBatchCallbacks> ownedCallbacks(adoptPtr(callbacks));
149 WebServiceWorkerCacheError error = m_error; 146 return callbacks->onError(new WebServiceWorkerCacheError(m_error));
150 return callbacks->onError(&error);
151 } 147 }
152 148
153 protected: 149 protected:
154 void checkUrlIfProvided(const KURL& url) 150 void checkUrlIfProvided(const KURL& url)
155 { 151 {
156 if (!m_expectedUrl) 152 if (!m_expectedUrl)
157 return; 153 return;
158 EXPECT_EQ(*m_expectedUrl, url); 154 EXPECT_EQ(*m_expectedUrl, url);
159 } 155 }
160 156
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 643
648 ScriptPromise addResult = cache->add(scriptState(), requestToRequestInfo(req uest), exceptionState()); 644 ScriptPromise addResult = cache->add(scriptState(), requestToRequestInfo(req uest), exceptionState());
649 645
650 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); 646 EXPECT_EQ(kNotImplementedString, getRejectString(addResult));
651 EXPECT_EQ(1, fetcher()->fetchCount()); 647 EXPECT_EQ(1, fetcher()->fetchCount());
652 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed()); 648 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed());
653 } 649 }
654 650
655 } // namespace 651 } // namespace
656 } // namespace blink 652 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/cachestorage/CacheStorageError.cpp ('k') | public/platform/WebServiceWorkerCacheError.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698