Commit 9d34b361 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Adjust some network interface APIs to avoid truncation errors.

Some blink public interfaces used size_t then truncated on the calls
internally to int. Use size_t throughout call graph.

BUG=879657

Change-Id: I3c124524c2e969b65e662a30d0c8898d9d4e01a5
Reviewed-on: https://chromium-review.googlesource.com/c/1354061Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611767}
parent f0bb9a2a
...@@ -262,7 +262,7 @@ void WebApplicationCacheHostImpl::DidReceiveResponseForMainResource( ...@@ -262,7 +262,7 @@ void WebApplicationCacheHostImpl::DidReceiveResponseForMainResource(
void WebApplicationCacheHostImpl::DidReceiveDataForMainResource( void WebApplicationCacheHostImpl::DidReceiveDataForMainResource(
const char* data, const char* data,
unsigned len) { size_t len) {
if (is_new_master_entry_ == OLD_ENTRY) if (is_new_master_entry_ == OLD_ENTRY)
return; return;
// TODO(michaeln): write me // TODO(michaeln): write me
......
...@@ -48,7 +48,7 @@ class WebApplicationCacheHostImpl : public blink::WebApplicationCacheHost { ...@@ -48,7 +48,7 @@ class WebApplicationCacheHostImpl : public blink::WebApplicationCacheHost {
void SelectCacheWithoutManifest() override; void SelectCacheWithoutManifest() override;
bool SelectCacheWithManifest(const blink::WebURL& manifestURL) override; bool SelectCacheWithManifest(const blink::WebURL& manifestURL) override;
void DidReceiveResponseForMainResource(const blink::WebURLResponse&) override; void DidReceiveResponseForMainResource(const blink::WebURLResponse&) override;
void DidReceiveDataForMainResource(const char* data, unsigned len) override; void DidReceiveDataForMainResource(const char* data, size_t len) override;
void DidFinishLoadingMainResource(bool success) override; void DidFinishLoadingMainResource(bool success) override;
blink::WebApplicationCacheHost::Status GetStatus() override; blink::WebApplicationCacheHost::Status GetStatus() override;
bool StartUpdate() override; bool StartUpdate() override;
......
...@@ -71,7 +71,7 @@ class SharedWorkerWebApplicationCacheHostImpl ...@@ -71,7 +71,7 @@ class SharedWorkerWebApplicationCacheHostImpl
const WebApplicationCacheHost* spawning_host) override {} const WebApplicationCacheHost* spawning_host) override {}
void DidReceiveResponseForMainResource( void DidReceiveResponseForMainResource(
const blink::WebURLResponse&) override {} const blink::WebURLResponse&) override {}
void DidReceiveDataForMainResource(const char* data, unsigned len) override {} void DidReceiveDataForMainResource(const char* data, size_t len) override {}
void DidFinishLoadingMainResource(bool success) override {} void DidFinishLoadingMainResource(bool success) override {}
// Cache selection is also different for workers. We know at construction // Cache selection is also different for workers. We know at construction
......
...@@ -100,7 +100,7 @@ class WebApplicationCacheHost { ...@@ -100,7 +100,7 @@ class WebApplicationCacheHost {
// Called as the main resource is retrieved. // Called as the main resource is retrieved.
virtual void DidReceiveResponseForMainResource(const WebURLResponse&) {} virtual void DidReceiveResponseForMainResource(const WebURLResponse&) {}
virtual void DidReceiveDataForMainResource(const char* data, unsigned len) {} virtual void DidReceiveDataForMainResource(const char* data, size_t len) {}
virtual void DidFinishLoadingMainResource(bool success) {} virtual void DidFinishLoadingMainResource(bool success) {}
// Called on behalf of the scriptable interface. // Called on behalf of the scriptable interface.
......
...@@ -955,7 +955,7 @@ static bool IsErrorStatusCode(int status_code) { ...@@ -955,7 +955,7 @@ static bool IsErrorStatusCode(int status_code) {
void InspectorNetworkAgent::DidReceiveData(unsigned long identifier, void InspectorNetworkAgent::DidReceiveData(unsigned long identifier,
DocumentLoader* loader, DocumentLoader* loader,
const char* data, const char* data,
int data_length) { size_t data_length) {
String request_id = IdentifiersFactory::RequestId(loader, identifier); String request_id = IdentifiersFactory::RequestId(loader, identifier);
if (data) { if (data) {
...@@ -984,7 +984,7 @@ void InspectorNetworkAgent::DidReceiveBlob(unsigned long identifier, ...@@ -984,7 +984,7 @@ void InspectorNetworkAgent::DidReceiveBlob(unsigned long identifier,
void InspectorNetworkAgent::DidReceiveEncodedDataLength( void InspectorNetworkAgent::DidReceiveEncodedDataLength(
DocumentLoader* loader, DocumentLoader* loader,
unsigned long identifier, unsigned long identifier,
int encoded_data_length) { size_t encoded_data_length) {
String request_id = IdentifiersFactory::RequestId(loader, identifier); String request_id = IdentifiersFactory::RequestId(loader, identifier);
resources_data_->AddPendingEncodedDataLength(request_id, encoded_data_length); resources_data_->AddPendingEncodedDataLength(request_id, encoded_data_length);
} }
......
...@@ -109,13 +109,13 @@ class CORE_EXPORT InspectorNetworkAgent final ...@@ -109,13 +109,13 @@ class CORE_EXPORT InspectorNetworkAgent final
void DidReceiveData(unsigned long identifier, void DidReceiveData(unsigned long identifier,
DocumentLoader*, DocumentLoader*,
const char* data, const char* data,
int data_length); size_t data_length);
void DidReceiveBlob(unsigned long identifier, void DidReceiveBlob(unsigned long identifier,
DocumentLoader*, DocumentLoader*,
scoped_refptr<BlobDataHandle>); scoped_refptr<BlobDataHandle>);
void DidReceiveEncodedDataLength(DocumentLoader*, void DidReceiveEncodedDataLength(DocumentLoader*,
unsigned long identifier, unsigned long identifier,
int encoded_data_length); size_t encoded_data_length);
void DidFinishLoading(unsigned long identifier, void DidFinishLoading(unsigned long identifier,
DocumentLoader*, DocumentLoader*,
TimeTicks monotonic_finish_time, TimeTicks monotonic_finish_time,
......
...@@ -368,20 +368,21 @@ NetworkResourcesData::Resources() { ...@@ -368,20 +368,21 @@ NetworkResourcesData::Resources() {
return result; return result;
} }
int NetworkResourcesData::GetAndClearPendingEncodedDataLength( int64_t NetworkResourcesData::GetAndClearPendingEncodedDataLength(
const String& request_id) { const String& request_id) {
ResourceData* resource_data = ResourceDataForRequestId(request_id); ResourceData* resource_data = ResourceDataForRequestId(request_id);
if (!resource_data) if (!resource_data)
return 0; return 0;
int pending_encoded_data_length = resource_data->PendingEncodedDataLength(); int64_t pending_encoded_data_length =
resource_data->PendingEncodedDataLength();
resource_data->ClearPendingEncodedDataLength(); resource_data->ClearPendingEncodedDataLength();
return pending_encoded_data_length; return pending_encoded_data_length;
} }
void NetworkResourcesData::AddPendingEncodedDataLength( void NetworkResourcesData::AddPendingEncodedDataLength(
const String& request_id, const String& request_id,
int encoded_data_length) { size_t encoded_data_length) {
ResourceData* resource_data = ResourceDataForRequestId(request_id); ResourceData* resource_data = ResourceDataForRequestId(request_id);
if (!resource_data) if (!resource_data)
return; return;
......
...@@ -152,11 +152,11 @@ class NetworkResourcesData final ...@@ -152,11 +152,11 @@ class NetworkResourcesData final
void SetCertificate(const Vector<AtomicString>& certificate) { void SetCertificate(const Vector<AtomicString>& certificate) {
certificate_ = certificate; certificate_ = certificate;
} }
int PendingEncodedDataLength() const { int64_t PendingEncodedDataLength() const {
return pending_encoded_data_length_; return pending_encoded_data_length_;
} }
void ClearPendingEncodedDataLength() { pending_encoded_data_length_ = 0; } void ClearPendingEncodedDataLength() { pending_encoded_data_length_ = 0; }
void AddPendingEncodedDataLength(int encoded_data_length) { void AddPendingEncodedDataLength(size_t encoded_data_length) {
pending_encoded_data_length_ += encoded_data_length; pending_encoded_data_length_ += encoded_data_length;
} }
void SetPostData(scoped_refptr<EncodedFormData> post_data) { void SetPostData(scoped_refptr<EncodedFormData> post_data) {
...@@ -189,7 +189,7 @@ class NetworkResourcesData final ...@@ -189,7 +189,7 @@ class NetworkResourcesData final
String mime_type_; String mime_type_;
String text_encoding_name_; String text_encoding_name_;
int64_t raw_header_size_; int64_t raw_header_size_;
int pending_encoded_data_length_; int64_t pending_encoded_data_length_;
scoped_refptr<SharedBuffer> buffer_; scoped_refptr<SharedBuffer> buffer_;
WeakMember<Resource> cached_resource_; WeakMember<Resource> cached_resource_;
...@@ -239,9 +239,9 @@ class NetworkResourcesData final ...@@ -239,9 +239,9 @@ class NetworkResourcesData final
const Vector<AtomicString>& certificate); const Vector<AtomicString>& certificate);
HeapVector<Member<ResourceData>> Resources(); HeapVector<Member<ResourceData>> Resources();
int GetAndClearPendingEncodedDataLength(const String& request_id); int64_t GetAndClearPendingEncodedDataLength(const String& request_id);
void AddPendingEncodedDataLength(const String& request_id, void AddPendingEncodedDataLength(const String& request_id,
int encoded_data_length); size_t encoded_data_length);
void Trace(blink::Visitor*); void Trace(blink::Visitor*);
private: private:
......
...@@ -165,7 +165,8 @@ void ProgressTracker::IncrementProgress(unsigned long identifier, ...@@ -165,7 +165,8 @@ void ProgressTracker::IncrementProgress(unsigned long identifier,
item->estimated_length = estimated_length; item->estimated_length = estimated_length;
} }
void ProgressTracker::IncrementProgress(unsigned long identifier, int length) { void ProgressTracker::IncrementProgress(unsigned long identifier,
size_t length) {
ProgressItem* item = progress_items_.at(identifier); ProgressItem* item = progress_items_.at(identifier);
if (!item) if (!item)
return; return;
......
...@@ -66,7 +66,7 @@ class CORE_EXPORT ProgressTracker final ...@@ -66,7 +66,7 @@ class CORE_EXPORT ProgressTracker final
void WillStartLoading(unsigned long identifier, ResourceLoadPriority); void WillStartLoading(unsigned long identifier, ResourceLoadPriority);
void IncrementProgress(unsigned long identifier, const ResourceResponse&); void IncrementProgress(unsigned long identifier, const ResourceResponse&);
void IncrementProgress(unsigned long identifier, int); void IncrementProgress(unsigned long identifier, size_t);
void CompleteProgress(unsigned long identifier); void CompleteProgress(unsigned long identifier);
private: private:
......
...@@ -94,9 +94,9 @@ interface CoreProbes { ...@@ -94,9 +94,9 @@ interface CoreProbes {
void willSendRequest([Keep] ExecutionContext*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse, const FetchInitiatorInfo&, ResourceType); void willSendRequest([Keep] ExecutionContext*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse, const FetchInitiatorInfo&, ResourceType);
void markResourceAsCached(LocalFrame*, DocumentLoader*, unsigned long identifier); void markResourceAsCached(LocalFrame*, DocumentLoader*, unsigned long identifier);
void didReceiveResourceResponse(ExecutionContext*, unsigned long identifier, DocumentLoader*, const ResourceResponse&, Resource*); void didReceiveResourceResponse(ExecutionContext*, unsigned long identifier, DocumentLoader*, const ResourceResponse&, Resource*);
void didReceiveData(ExecutionContext*, unsigned long identifier, DocumentLoader*, const char* data, int dataLength); void didReceiveData(ExecutionContext*, unsigned long identifier, DocumentLoader*, const char* data, size_t dataLength);
void didReceiveBlob(ExecutionContext*, unsigned long identifier, DocumentLoader*, BlobDataHandle*); void didReceiveBlob(ExecutionContext*, unsigned long identifier, DocumentLoader*, BlobDataHandle*);
void didReceiveEncodedDataLength(ExecutionContext*, DocumentLoader* loader, unsigned long identifier, int encodedDataLength); void didReceiveEncodedDataLength(ExecutionContext*, DocumentLoader* loader, unsigned long identifier, size_t encodedDataLength);
void didFinishLoading(ExecutionContext*, unsigned long identifier, DocumentLoader*, TimeTicks finishTime, int64_t encoded_data_length, int64_t decodedBodyLength, bool should_report_corb_blocking); void didFinishLoading(ExecutionContext*, unsigned long identifier, DocumentLoader*, TimeTicks finishTime, int64_t encoded_data_length, int64_t decodedBodyLength, bool should_report_corb_blocking);
void didReceiveCorsRedirectResponse(ExecutionContext*, unsigned long identifier, DocumentLoader*, const ResourceResponse&, Resource*); void didReceiveCorsRedirectResponse(ExecutionContext*, unsigned long identifier, DocumentLoader*, const ResourceResponse&, Resource*);
void didFailLoading(ExecutionContext*, unsigned long identifier, DocumentLoader*, const ResourceError&); void didFailLoading(ExecutionContext*, unsigned long identifier, DocumentLoader*, const ResourceError&);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment