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

Side by Side Diff: third_party/WebKit/Source/core/inspector/NetworkResourcesData.cpp

Issue 2807533005: Avoid duplicate functions/code in core/inspector: IsErrorStatusCode (Closed)
Patch Set: Rebased past blink rename Created 3 years, 8 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 10 *
(...skipping 18 matching lines...) Expand all
29 #include "core/inspector/NetworkResourcesData.h" 29 #include "core/inspector/NetworkResourcesData.h"
30 30
31 #include <memory> 31 #include <memory>
32 #include "core/dom/DOMImplementation.h" 32 #include "core/dom/DOMImplementation.h"
33 #include "platform/SharedBuffer.h" 33 #include "platform/SharedBuffer.h"
34 #include "platform/loader/fetch/Resource.h" 34 #include "platform/loader/fetch/Resource.h"
35 #include "platform/loader/fetch/ResourceResponse.h" 35 #include "platform/loader/fetch/ResourceResponse.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 static bool IsErrorStatusCode(int status_code) { 39 static bool IsHTTPErrorStatusCode(int status_code) {
40 return status_code >= 400; 40 return status_code >= 400;
41 } 41 }
42 42
43 XHRReplayData* XHRReplayData::Create(ExecutionContext* execution_context, 43 XHRReplayData* XHRReplayData::Create(ExecutionContext* execution_context,
44 const AtomicString& method, 44 const AtomicString& method,
45 const KURL& url, 45 const KURL& url,
46 bool async, 46 bool async,
47 PassRefPtr<EncodedFormData> form_data, 47 PassRefPtr<EncodedFormData> form_data,
48 bool include_credentials) { 48 bool include_credentials) {
49 return new XHRReplayData(execution_context, method, url, async, 49 return new XHRReplayData(execution_context, method, url, async,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 Resource* cached_resource) { 131 Resource* cached_resource) {
132 cached_resource_ = cached_resource; 132 cached_resource_ = cached_resource;
133 } 133 }
134 134
135 void NetworkResourcesData::ResourceData::ClearWeakMembers(Visitor* visitor) { 135 void NetworkResourcesData::ResourceData::ClearWeakMembers(Visitor* visitor) {
136 if (!cached_resource_ || ThreadHeap::IsHeapObjectAlive(cached_resource_)) 136 if (!cached_resource_ || ThreadHeap::IsHeapObjectAlive(cached_resource_))
137 return; 137 return;
138 138
139 // Mark loaded resources or resources without the buffer as loaded. 139 // Mark loaded resources or resources without the buffer as loaded.
140 if (cached_resource_->IsLoaded() || !cached_resource_->ResourceBuffer()) { 140 if (cached_resource_->IsLoaded() || !cached_resource_->ResourceBuffer()) {
141 if (!IsErrorStatusCode(cached_resource_->GetResponse().HttpStatusCode())) { 141 if (!IsHTTPErrorStatusCode(
142 cached_resource_->GetResponse().HttpStatusCode())) {
142 String content; 143 String content;
143 bool base64_encoded; 144 bool base64_encoded;
144 if (InspectorPageAgent::CachedResourceContent(cached_resource_, &content, 145 if (InspectorPageAgent::CachedResourceContent(cached_resource_, &content,
145 &base64_encoded)) 146 &base64_encoded))
146 network_resources_data_->SetResourceContent(RequestId(), content, 147 network_resources_data_->SetResourceContent(RequestId(), content,
147 base64_encoded); 148 base64_encoded);
148 } 149 }
149 } else { 150 } else {
150 // We could be evicting resource being loaded, save the loaded part, the 151 // We could be evicting resource being loaded, save the loaded part, the
151 // rest will be appended. 152 // rest will be appended.
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 while (size > maximum_resources_content_size_ - content_size_) { 428 while (size > maximum_resources_content_size_ - content_size_) {
428 String request_id = request_ids_deque_.TakeFirst(); 429 String request_id = request_ids_deque_.TakeFirst();
429 ResourceData* resource_data = ResourceDataForRequestId(request_id); 430 ResourceData* resource_data = ResourceDataForRequestId(request_id);
430 if (resource_data) 431 if (resource_data)
431 content_size_ -= resource_data->EvictContent(); 432 content_size_ -= resource_data->EvictContent();
432 } 433 }
433 return true; 434 return true;
434 } 435 }
435 436
436 } // namespace blink 437 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698