OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 m_rawData->append(data, dataLength); | 157 m_rawData->append(data, dataLength); |
158 } | 158 } |
159 | 159 |
160 virtual void didFinishLoading() { | 160 virtual void didFinishLoading() { |
161 String result; | 161 String result; |
162 bool base64Encoded; | 162 bool base64Encoded; |
163 if (InspectorPageAgent::sharedBufferContent( | 163 if (InspectorPageAgent::sharedBufferContent( |
164 m_rawData, m_mimeType, m_textEncodingName, &result, &base64Encoded)) | 164 m_rawData, m_mimeType, m_textEncodingName, &result, &base64Encoded)) |
165 m_callback->sendSuccess(result, base64Encoded); | 165 m_callback->sendSuccess(result, base64Encoded); |
166 else | 166 else |
167 m_callback->sendFailure("Couldn't encode data"); | 167 m_callback->sendFailure(Response::Error("Couldn't encode data")); |
168 dispose(); | 168 dispose(); |
169 } | 169 } |
170 | 170 |
171 virtual void didFail(FileError::ErrorCode) { | 171 virtual void didFail(FileError::ErrorCode) { |
172 m_callback->sendFailure("Couldn't read BLOB"); | 172 m_callback->sendFailure(Response::Error("Couldn't read BLOB")); |
173 dispose(); | 173 dispose(); |
174 } | 174 } |
175 | 175 |
176 private: | 176 private: |
177 void dispose() { | 177 void dispose() { |
178 m_rawData.clear(); | 178 m_rawData.clear(); |
179 delete this; | 179 delete this; |
180 } | 180 } |
181 | 181 |
182 RefPtr<BlobDataHandle> m_blob; | 182 RefPtr<BlobDataHandle> m_blob; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 return protocol::Network::BlockedReasonEnum::SubresourceFilter; | 242 return protocol::Network::BlockedReasonEnum::SubresourceFilter; |
243 case ResourceRequestBlockedReasonOther: | 243 case ResourceRequestBlockedReasonOther: |
244 return protocol::Network::BlockedReasonEnum::Other; | 244 return protocol::Network::BlockedReasonEnum::Other; |
245 case ResourceRequestBlockedReasonNone: | 245 case ResourceRequestBlockedReasonNone: |
246 default: | 246 default: |
247 NOTREACHED(); | 247 NOTREACHED(); |
248 return protocol::Network::BlockedReasonEnum::Other; | 248 return protocol::Network::BlockedReasonEnum::Other; |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 WebConnectionType toWebConnectionType(ErrorString* errorString, | 252 WebConnectionType toWebConnectionType(const String& connectionType) { |
253 const String& connectionType) { | |
254 if (connectionType == protocol::Network::ConnectionTypeEnum::None) | 253 if (connectionType == protocol::Network::ConnectionTypeEnum::None) |
255 return WebConnectionTypeNone; | 254 return WebConnectionTypeNone; |
256 if (connectionType == protocol::Network::ConnectionTypeEnum::Cellular2g) | 255 if (connectionType == protocol::Network::ConnectionTypeEnum::Cellular2g) |
257 return WebConnectionTypeCellular2G; | 256 return WebConnectionTypeCellular2G; |
258 if (connectionType == protocol::Network::ConnectionTypeEnum::Cellular3g) | 257 if (connectionType == protocol::Network::ConnectionTypeEnum::Cellular3g) |
259 return WebConnectionTypeCellular3G; | 258 return WebConnectionTypeCellular3G; |
260 if (connectionType == protocol::Network::ConnectionTypeEnum::Cellular4g) | 259 if (connectionType == protocol::Network::ConnectionTypeEnum::Cellular4g) |
261 return WebConnectionTypeCellular4G; | 260 return WebConnectionTypeCellular4G; |
262 if (connectionType == protocol::Network::ConnectionTypeEnum::Bluetooth) | 261 if (connectionType == protocol::Network::ConnectionTypeEnum::Bluetooth) |
263 return WebConnectionTypeBluetooth; | 262 return WebConnectionTypeBluetooth; |
264 if (connectionType == protocol::Network::ConnectionTypeEnum::Ethernet) | 263 if (connectionType == protocol::Network::ConnectionTypeEnum::Ethernet) |
265 return WebConnectionTypeEthernet; | 264 return WebConnectionTypeEthernet; |
266 if (connectionType == protocol::Network::ConnectionTypeEnum::Wifi) | 265 if (connectionType == protocol::Network::ConnectionTypeEnum::Wifi) |
267 return WebConnectionTypeWifi; | 266 return WebConnectionTypeWifi; |
268 if (connectionType == protocol::Network::ConnectionTypeEnum::Wimax) | 267 if (connectionType == protocol::Network::ConnectionTypeEnum::Wimax) |
269 return WebConnectionTypeWimax; | 268 return WebConnectionTypeWimax; |
270 if (connectionType == protocol::Network::ConnectionTypeEnum::Other) | 269 if (connectionType == protocol::Network::ConnectionTypeEnum::Other) |
271 return WebConnectionTypeOther; | 270 return WebConnectionTypeOther; |
272 *errorString = "Unknown connection type"; | |
273 return WebConnectionTypeUnknown; | 271 return WebConnectionTypeUnknown; |
274 } | 272 } |
275 | 273 |
276 } // namespace | 274 } // namespace |
277 | 275 |
278 void InspectorNetworkAgent::restore() { | 276 void InspectorNetworkAgent::restore() { |
279 if (m_state->booleanProperty(NetworkAgentState::networkAgentEnabled, false)) { | 277 if (m_state->booleanProperty(NetworkAgentState::networkAgentEnabled, false)) { |
280 enable(m_state->integerProperty(NetworkAgentState::totalBufferSize, | 278 enable(m_state->integerProperty(NetworkAgentState::totalBufferSize, |
281 maximumTotalBufferSize), | 279 maximumTotalBufferSize), |
282 m_state->integerProperty(NetworkAgentState::resourceBufferSize, | 280 m_state->integerProperty(NetworkAgentState::resourceBufferSize, |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 std::move(frameObject)); | 1124 std::move(frameObject)); |
1127 } | 1125 } |
1128 | 1126 |
1129 void InspectorNetworkAgent::didReceiveWebSocketFrameError( | 1127 void InspectorNetworkAgent::didReceiveWebSocketFrameError( |
1130 unsigned long identifier, | 1128 unsigned long identifier, |
1131 const String& errorMessage) { | 1129 const String& errorMessage) { |
1132 frontend()->webSocketFrameError(IdentifiersFactory::requestId(identifier), | 1130 frontend()->webSocketFrameError(IdentifiersFactory::requestId(identifier), |
1133 monotonicallyIncreasingTime(), errorMessage); | 1131 monotonicallyIncreasingTime(), errorMessage); |
1134 } | 1132 } |
1135 | 1133 |
1136 void InspectorNetworkAgent::enable(ErrorString*, | 1134 Response InspectorNetworkAgent::enable(Maybe<int> totalBufferSize, |
1137 const Maybe<int>& totalBufferSize, | 1135 Maybe<int> resourceBufferSize) { |
1138 const Maybe<int>& resourceBufferSize) { | |
1139 enable(totalBufferSize.fromMaybe(maximumTotalBufferSize), | 1136 enable(totalBufferSize.fromMaybe(maximumTotalBufferSize), |
1140 resourceBufferSize.fromMaybe(maximumResourceBufferSize)); | 1137 resourceBufferSize.fromMaybe(maximumResourceBufferSize)); |
| 1138 return Response::OK(); |
1141 } | 1139 } |
1142 | 1140 |
1143 void InspectorNetworkAgent::enable(int totalBufferSize, | 1141 void InspectorNetworkAgent::enable(int totalBufferSize, |
1144 int resourceBufferSize) { | 1142 int resourceBufferSize) { |
1145 if (!frontend()) | 1143 if (!frontend()) |
1146 return; | 1144 return; |
1147 m_resourcesData->setResourcesDataSizeLimits(totalBufferSize, | 1145 m_resourcesData->setResourcesDataSizeLimits(totalBufferSize, |
1148 resourceBufferSize); | 1146 resourceBufferSize); |
1149 m_state->setBoolean(NetworkAgentState::networkAgentEnabled, true); | 1147 m_state->setBoolean(NetworkAgentState::networkAgentEnabled, true); |
1150 m_state->setInteger(NetworkAgentState::totalBufferSize, totalBufferSize); | 1148 m_state->setInteger(NetworkAgentState::totalBufferSize, totalBufferSize); |
1151 m_state->setInteger(NetworkAgentState::resourceBufferSize, | 1149 m_state->setInteger(NetworkAgentState::resourceBufferSize, |
1152 resourceBufferSize); | 1150 resourceBufferSize); |
1153 m_instrumentingAgents->addInspectorNetworkAgent(this); | 1151 m_instrumentingAgents->addInspectorNetworkAgent(this); |
1154 } | 1152 } |
1155 | 1153 |
1156 void InspectorNetworkAgent::disable(ErrorString*) { | 1154 Response InspectorNetworkAgent::disable() { |
1157 DCHECK(!m_pendingRequest); | 1155 DCHECK(!m_pendingRequest); |
1158 m_state->setBoolean(NetworkAgentState::networkAgentEnabled, false); | 1156 m_state->setBoolean(NetworkAgentState::networkAgentEnabled, false); |
1159 m_state->setString(NetworkAgentState::userAgentOverride, ""); | 1157 m_state->setString(NetworkAgentState::userAgentOverride, ""); |
1160 m_instrumentingAgents->removeInspectorNetworkAgent(this); | 1158 m_instrumentingAgents->removeInspectorNetworkAgent(this); |
1161 m_resourcesData->clear(); | 1159 m_resourcesData->clear(); |
1162 m_knownRequestIdMap.clear(); | 1160 m_knownRequestIdMap.clear(); |
| 1161 return Response::OK(); |
1163 } | 1162 } |
1164 | 1163 |
1165 void InspectorNetworkAgent::setUserAgentOverride(ErrorString* errorString, | 1164 Response InspectorNetworkAgent::setUserAgentOverride(const String& userAgent) { |
1166 const String& userAgent) { | |
1167 if (userAgent.contains('\n') || userAgent.contains('\r') || | 1165 if (userAgent.contains('\n') || userAgent.contains('\r') || |
1168 userAgent.contains('\0')) { | 1166 userAgent.contains('\0')) { |
1169 *errorString = "Invalid characters found in userAgent"; | 1167 return Response::Error("Invalid characters found in userAgent"); |
1170 return; | |
1171 } | 1168 } |
1172 m_state->setString(NetworkAgentState::userAgentOverride, userAgent); | 1169 m_state->setString(NetworkAgentState::userAgentOverride, userAgent); |
| 1170 return Response::OK(); |
1173 } | 1171 } |
1174 | 1172 |
1175 void InspectorNetworkAgent::setExtraHTTPHeaders( | 1173 Response InspectorNetworkAgent::setExtraHTTPHeaders( |
1176 ErrorString*, | |
1177 const std::unique_ptr<protocol::Network::Headers> headers) { | 1174 const std::unique_ptr<protocol::Network::Headers> headers) { |
1178 m_state->setObject(NetworkAgentState::extraRequestHeaders, | 1175 m_state->setObject(NetworkAgentState::extraRequestHeaders, |
1179 headers->serialize()); | 1176 headers->serialize()); |
| 1177 return Response::OK(); |
1180 } | 1178 } |
1181 | 1179 |
1182 bool InspectorNetworkAgent::canGetResponseBodyBlob(const String& requestId) { | 1180 bool InspectorNetworkAgent::canGetResponseBodyBlob(const String& requestId) { |
1183 NetworkResourcesData::ResourceData const* resourceData = | 1181 NetworkResourcesData::ResourceData const* resourceData = |
1184 m_resourcesData->data(requestId); | 1182 m_resourcesData->data(requestId); |
1185 BlobDataHandle* blob = | 1183 BlobDataHandle* blob = |
1186 resourceData ? resourceData->downloadedFileBlob() : nullptr; | 1184 resourceData ? resourceData->downloadedFileBlob() : nullptr; |
1187 if (!blob) | 1185 if (!blob) |
1188 return false; | 1186 return false; |
1189 LocalFrame* frame = | 1187 LocalFrame* frame = |
(...skipping 16 matching lines...) Expand all Loading... |
1206 client->start(document); | 1204 client->start(document); |
1207 } | 1205 } |
1208 | 1206 |
1209 void InspectorNetworkAgent::getResponseBody( | 1207 void InspectorNetworkAgent::getResponseBody( |
1210 const String& requestId, | 1208 const String& requestId, |
1211 std::unique_ptr<GetResponseBodyCallback> passCallback) { | 1209 std::unique_ptr<GetResponseBodyCallback> passCallback) { |
1212 std::unique_ptr<GetResponseBodyCallback> callback = std::move(passCallback); | 1210 std::unique_ptr<GetResponseBodyCallback> callback = std::move(passCallback); |
1213 NetworkResourcesData::ResourceData const* resourceData = | 1211 NetworkResourcesData::ResourceData const* resourceData = |
1214 m_resourcesData->data(requestId); | 1212 m_resourcesData->data(requestId); |
1215 if (!resourceData) { | 1213 if (!resourceData) { |
1216 callback->sendFailure("No resource with given identifier found"); | 1214 callback->sendFailure( |
| 1215 Response::Error("No resource with given identifier found")); |
1217 return; | 1216 return; |
1218 } | 1217 } |
1219 | 1218 |
1220 // XHR with ResponseTypeBlob should be returned as blob. | 1219 // XHR with ResponseTypeBlob should be returned as blob. |
1221 if (resourceData->xhrReplayData() && canGetResponseBodyBlob(requestId)) { | 1220 if (resourceData->xhrReplayData() && canGetResponseBodyBlob(requestId)) { |
1222 getResponseBodyBlob(requestId, std::move(callback)); | 1221 getResponseBodyBlob(requestId, std::move(callback)); |
1223 return; | 1222 return; |
1224 } | 1223 } |
1225 | 1224 |
1226 if (resourceData->hasContent()) { | 1225 if (resourceData->hasContent()) { |
1227 callback->sendSuccess(resourceData->content(), | 1226 callback->sendSuccess(resourceData->content(), |
1228 resourceData->base64Encoded()); | 1227 resourceData->base64Encoded()); |
1229 return; | 1228 return; |
1230 } | 1229 } |
1231 | 1230 |
1232 if (resourceData->isContentEvicted()) { | 1231 if (resourceData->isContentEvicted()) { |
1233 callback->sendFailure("Request content was evicted from inspector cache"); | 1232 callback->sendFailure( |
| 1233 Response::Error("Request content was evicted from inspector cache")); |
1234 return; | 1234 return; |
1235 } | 1235 } |
1236 | 1236 |
1237 if (resourceData->buffer() && !resourceData->textEncodingName().isNull()) { | 1237 if (resourceData->buffer() && !resourceData->textEncodingName().isNull()) { |
1238 String result; | 1238 String result; |
1239 bool base64Encoded; | 1239 bool base64Encoded; |
1240 bool success = InspectorPageAgent::sharedBufferContent( | 1240 bool success = InspectorPageAgent::sharedBufferContent( |
1241 resourceData->buffer(), resourceData->mimeType(), | 1241 resourceData->buffer(), resourceData->mimeType(), |
1242 resourceData->textEncodingName(), &result, &base64Encoded); | 1242 resourceData->textEncodingName(), &result, &base64Encoded); |
1243 DCHECK(success); | 1243 DCHECK(success); |
1244 callback->sendSuccess(result, base64Encoded); | 1244 callback->sendSuccess(result, base64Encoded); |
1245 return; | 1245 return; |
1246 } | 1246 } |
1247 | 1247 |
1248 if (resourceData->cachedResource()) { | 1248 if (resourceData->cachedResource()) { |
1249 String content; | 1249 String content; |
1250 bool base64Encoded = false; | 1250 bool base64Encoded = false; |
1251 if (InspectorPageAgent::cachedResourceContent( | 1251 if (InspectorPageAgent::cachedResourceContent( |
1252 resourceData->cachedResource(), &content, &base64Encoded)) { | 1252 resourceData->cachedResource(), &content, &base64Encoded)) { |
1253 callback->sendSuccess(content, base64Encoded); | 1253 callback->sendSuccess(content, base64Encoded); |
1254 return; | 1254 return; |
1255 } | 1255 } |
1256 } | 1256 } |
1257 | 1257 |
1258 if (canGetResponseBodyBlob(requestId)) { | 1258 if (canGetResponseBodyBlob(requestId)) { |
1259 getResponseBodyBlob(requestId, std::move(callback)); | 1259 getResponseBodyBlob(requestId, std::move(callback)); |
1260 return; | 1260 return; |
1261 } | 1261 } |
1262 | 1262 |
1263 callback->sendFailure("No data found for resource with given identifier"); | 1263 callback->sendFailure( |
| 1264 Response::Error("No data found for resource with given identifier")); |
1264 } | 1265 } |
1265 | 1266 |
1266 void InspectorNetworkAgent::addBlockedURL(ErrorString*, const String& url) { | 1267 Response InspectorNetworkAgent::addBlockedURL(const String& url) { |
1267 protocol::DictionaryValue* blockedURLs = | 1268 protocol::DictionaryValue* blockedURLs = |
1268 m_state->getObject(NetworkAgentState::blockedURLs); | 1269 m_state->getObject(NetworkAgentState::blockedURLs); |
1269 if (!blockedURLs) { | 1270 if (!blockedURLs) { |
1270 std::unique_ptr<protocol::DictionaryValue> newList = | 1271 std::unique_ptr<protocol::DictionaryValue> newList = |
1271 protocol::DictionaryValue::create(); | 1272 protocol::DictionaryValue::create(); |
1272 blockedURLs = newList.get(); | 1273 blockedURLs = newList.get(); |
1273 m_state->setObject(NetworkAgentState::blockedURLs, std::move(newList)); | 1274 m_state->setObject(NetworkAgentState::blockedURLs, std::move(newList)); |
1274 } | 1275 } |
1275 blockedURLs->setBoolean(url, true); | 1276 blockedURLs->setBoolean(url, true); |
| 1277 return Response::OK(); |
1276 } | 1278 } |
1277 | 1279 |
1278 void InspectorNetworkAgent::removeBlockedURL(ErrorString*, const String& url) { | 1280 Response InspectorNetworkAgent::removeBlockedURL(const String& url) { |
1279 protocol::DictionaryValue* blockedURLs = | 1281 protocol::DictionaryValue* blockedURLs = |
1280 m_state->getObject(NetworkAgentState::blockedURLs); | 1282 m_state->getObject(NetworkAgentState::blockedURLs); |
1281 if (blockedURLs) | 1283 if (blockedURLs) |
1282 blockedURLs->remove(url); | 1284 blockedURLs->remove(url); |
| 1285 return Response::OK(); |
1283 } | 1286 } |
1284 | 1287 |
1285 void InspectorNetworkAgent::replayXHR(ErrorString*, const String& requestId) { | 1288 Response InspectorNetworkAgent::replayXHR(const String& requestId) { |
1286 String actualRequestId = requestId; | 1289 String actualRequestId = requestId; |
1287 | 1290 |
1288 XHRReplayData* xhrReplayData = m_resourcesData->xhrReplayData(requestId); | 1291 XHRReplayData* xhrReplayData = m_resourcesData->xhrReplayData(requestId); |
1289 if (!xhrReplayData) | 1292 if (!xhrReplayData) |
1290 return; | 1293 return Response::Error("Given id does not correspond to XHR"); |
1291 | 1294 |
1292 ExecutionContext* executionContext = xhrReplayData->getExecutionContext(); | 1295 ExecutionContext* executionContext = xhrReplayData->getExecutionContext(); |
1293 if (!executionContext) { | 1296 if (!executionContext) { |
1294 m_resourcesData->setXHRReplayData(requestId, 0); | 1297 m_resourcesData->setXHRReplayData(requestId, 0); |
1295 return; | 1298 return Response::Error("Document is already detached"); |
1296 } | 1299 } |
1297 | 1300 |
1298 XMLHttpRequest* xhr = XMLHttpRequest::create(executionContext); | 1301 XMLHttpRequest* xhr = XMLHttpRequest::create(executionContext); |
1299 | 1302 |
1300 executionContext->removeURLFromMemoryCache(xhrReplayData->url()); | 1303 executionContext->removeURLFromMemoryCache(xhrReplayData->url()); |
1301 | 1304 |
1302 xhr->open(xhrReplayData->method(), xhrReplayData->url(), | 1305 xhr->open(xhrReplayData->method(), xhrReplayData->url(), |
1303 xhrReplayData->async(), IGNORE_EXCEPTION); | 1306 xhrReplayData->async(), IGNORE_EXCEPTION); |
1304 if (xhrReplayData->includeCredentials()) | 1307 if (xhrReplayData->includeCredentials()) |
1305 xhr->setWithCredentials(true, IGNORE_EXCEPTION); | 1308 xhr->setWithCredentials(true, IGNORE_EXCEPTION); |
1306 for (const auto& header : xhrReplayData->headers()) | 1309 for (const auto& header : xhrReplayData->headers()) |
1307 xhr->setRequestHeader(header.key, header.value, IGNORE_EXCEPTION); | 1310 xhr->setRequestHeader(header.key, header.value, IGNORE_EXCEPTION); |
1308 xhr->sendForInspectorXHRReplay(xhrReplayData->formData(), IGNORE_EXCEPTION); | 1311 xhr->sendForInspectorXHRReplay(xhrReplayData->formData(), IGNORE_EXCEPTION); |
1309 | 1312 |
1310 m_replayXHRs.add(xhr); | 1313 m_replayXHRs.add(xhr); |
| 1314 return Response::OK(); |
1311 } | 1315 } |
1312 | 1316 |
1313 void InspectorNetworkAgent::setMonitoringXHREnabled(ErrorString*, | 1317 Response InspectorNetworkAgent::setMonitoringXHREnabled(bool enabled) { |
1314 bool enabled) { | |
1315 m_state->setBoolean(NetworkAgentState::monitoringXHR, enabled); | 1318 m_state->setBoolean(NetworkAgentState::monitoringXHR, enabled); |
| 1319 return Response::OK(); |
1316 } | 1320 } |
1317 | 1321 |
1318 void InspectorNetworkAgent::canClearBrowserCache(ErrorString*, bool* result) { | 1322 Response InspectorNetworkAgent::canClearBrowserCache(bool* result) { |
1319 *result = true; | 1323 *result = true; |
| 1324 return Response::OK(); |
1320 } | 1325 } |
1321 | 1326 |
1322 void InspectorNetworkAgent::canClearBrowserCookies(ErrorString*, bool* result) { | 1327 Response InspectorNetworkAgent::canClearBrowserCookies(bool* result) { |
1323 *result = true; | 1328 *result = true; |
| 1329 return Response::OK(); |
1324 } | 1330 } |
1325 | 1331 |
1326 void InspectorNetworkAgent::emulateNetworkConditions( | 1332 Response InspectorNetworkAgent::emulateNetworkConditions( |
1327 ErrorString* errorString, | |
1328 bool offline, | 1333 bool offline, |
1329 double latency, | 1334 double latency, |
1330 double downloadThroughput, | 1335 double downloadThroughput, |
1331 double uploadThroughput, | 1336 double uploadThroughput, |
1332 const Maybe<String>& connectionType) { | 1337 Maybe<String> connectionType) { |
1333 WebConnectionType type = WebConnectionTypeUnknown; | 1338 WebConnectionType type = WebConnectionTypeUnknown; |
1334 if (connectionType.isJust()) { | 1339 if (connectionType.isJust()) { |
1335 type = toWebConnectionType(errorString, connectionType.fromJust()); | 1340 type = toWebConnectionType(connectionType.fromJust()); |
1336 if (!errorString->isEmpty()) | 1341 if (type == WebConnectionTypeUnknown) |
1337 return; | 1342 return Response::Error("Unknown connection type"); |
1338 } | 1343 } |
1339 // TODO(dgozman): networkStateNotifier is per-process. It would be nice to | 1344 // TODO(dgozman): networkStateNotifier is per-process. It would be nice to |
1340 // have per-frame override instead. | 1345 // have per-frame override instead. |
1341 if (offline || latency || downloadThroughput || uploadThroughput) | 1346 if (offline || latency || downloadThroughput || uploadThroughput) |
1342 networkStateNotifier().setOverride(!offline, type, | 1347 networkStateNotifier().setOverride(!offline, type, |
1343 downloadThroughput / (1024 * 1024 / 8)); | 1348 downloadThroughput / (1024 * 1024 / 8)); |
1344 else | 1349 else |
1345 networkStateNotifier().clearOverride(); | 1350 networkStateNotifier().clearOverride(); |
| 1351 return Response::OK(); |
1346 } | 1352 } |
1347 | 1353 |
1348 void InspectorNetworkAgent::setCacheDisabled(ErrorString*, bool cacheDisabled) { | 1354 Response InspectorNetworkAgent::setCacheDisabled(bool cacheDisabled) { |
1349 m_state->setBoolean(NetworkAgentState::cacheDisabled, cacheDisabled); | 1355 m_state->setBoolean(NetworkAgentState::cacheDisabled, cacheDisabled); |
1350 if (cacheDisabled) | 1356 if (cacheDisabled) |
1351 memoryCache()->evictResources(); | 1357 memoryCache()->evictResources(); |
| 1358 return Response::OK(); |
1352 } | 1359 } |
1353 | 1360 |
1354 void InspectorNetworkAgent::setBypassServiceWorker(ErrorString*, bool bypass) { | 1361 Response InspectorNetworkAgent::setBypassServiceWorker(bool bypass) { |
1355 m_state->setBoolean(NetworkAgentState::bypassServiceWorker, bypass); | 1362 m_state->setBoolean(NetworkAgentState::bypassServiceWorker, bypass); |
| 1363 return Response::OK(); |
1356 } | 1364 } |
1357 | 1365 |
1358 void InspectorNetworkAgent::setDataSizeLimitsForTest(ErrorString*, | 1366 Response InspectorNetworkAgent::setDataSizeLimitsForTest(int maxTotal, |
1359 int maxTotal, | 1367 int maxResource) { |
1360 int maxResource) { | |
1361 m_resourcesData->setResourcesDataSizeLimits(maxTotal, maxResource); | 1368 m_resourcesData->setResourcesDataSizeLimits(maxTotal, maxResource); |
| 1369 return Response::OK(); |
1362 } | 1370 } |
1363 | 1371 |
1364 void InspectorNetworkAgent::getCertificate( | 1372 Response InspectorNetworkAgent::getCertificate( |
1365 ErrorString*, | |
1366 const String& origin, | 1373 const String& origin, |
1367 std::unique_ptr<protocol::Array<String>>* certificate) { | 1374 std::unique_ptr<protocol::Array<String>>* certificate) { |
1368 *certificate = protocol::Array<String>::create(); | 1375 *certificate = protocol::Array<String>::create(); |
1369 RefPtr<SecurityOrigin> securityOrigin = | 1376 RefPtr<SecurityOrigin> securityOrigin = |
1370 SecurityOrigin::createFromString(origin); | 1377 SecurityOrigin::createFromString(origin); |
1371 for (auto& resource : m_resourcesData->resources()) { | 1378 for (auto& resource : m_resourcesData->resources()) { |
1372 RefPtr<SecurityOrigin> resourceOrigin = | 1379 RefPtr<SecurityOrigin> resourceOrigin = |
1373 SecurityOrigin::create(resource->requestedURL()); | 1380 SecurityOrigin::create(resource->requestedURL()); |
1374 if (resourceOrigin->isSameSchemeHostPort(securityOrigin.get())) { | 1381 if (resourceOrigin->isSameSchemeHostPort(securityOrigin.get())) { |
1375 for (auto& cert : resource->certificate()) | 1382 for (auto& cert : resource->certificate()) |
1376 certificate->get()->addItem(base64Encode(cert.latin1())); | 1383 certificate->get()->addItem(base64Encode(cert.latin1())); |
1377 return; | 1384 return Response::OK(); |
1378 } | 1385 } |
1379 } | 1386 } |
| 1387 return Response::OK(); |
1380 } | 1388 } |
1381 | 1389 |
1382 void InspectorNetworkAgent::didCommitLoad(LocalFrame* frame, | 1390 void InspectorNetworkAgent::didCommitLoad(LocalFrame* frame, |
1383 DocumentLoader* loader) { | 1391 DocumentLoader* loader) { |
1384 if (loader->frame() != m_inspectedFrames->root()) | 1392 if (loader->frame() != m_inspectedFrames->root()) |
1385 return; | 1393 return; |
1386 | 1394 |
1387 if (m_state->booleanProperty(NetworkAgentState::cacheDisabled, false)) | 1395 if (m_state->booleanProperty(NetworkAgentState::cacheDisabled, false)) |
1388 memoryCache()->evictResources(MemoryCache::DoNotEvictUnusedPreloads); | 1396 memoryCache()->evictResources(MemoryCache::DoNotEvictUnusedPreloads); |
1389 | 1397 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 m_isRecalculatingStyle(false), | 1450 m_isRecalculatingStyle(false), |
1443 m_removeFinishedReplayXHRTimer( | 1451 m_removeFinishedReplayXHRTimer( |
1444 this, | 1452 this, |
1445 &InspectorNetworkAgent::removeFinishedReplayXHRFired) {} | 1453 &InspectorNetworkAgent::removeFinishedReplayXHRFired) {} |
1446 | 1454 |
1447 bool InspectorNetworkAgent::shouldForceCORSPreflight() { | 1455 bool InspectorNetworkAgent::shouldForceCORSPreflight() { |
1448 return m_state->booleanProperty(NetworkAgentState::cacheDisabled, false); | 1456 return m_state->booleanProperty(NetworkAgentState::cacheDisabled, false); |
1449 } | 1457 } |
1450 | 1458 |
1451 } // namespace blink | 1459 } // namespace blink |
OLD | NEW |