summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhoro <horo@chromium.org>2016-03-01 10:23:42 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-01 18:25:14 +0000
commit22cfef8f621c1ce431f3f0b7d4a3d8cafec9382f (patch)
tree2b2c3a9f7b85a8f28c5e4dc6685e3c989c2510c2
parent7fdc1e4512c4aeeb39415656da42fbc67d2a94e6 (diff)
downloadchromium_src-22cfef8f621c1ce431f3f0b7d4a3d8cafec9382f.zip
chromium_src-22cfef8f621c1ce431f3f0b7d4a3d8cafec9382f.tar.gz
chromium_src-22cfef8f621c1ce431f3f0b7d4a3d8cafec9382f.tar.bz2
Reland of Pipe response_time from FetchManager to CacheStorage and ServiceWorkerURLRequestJob. (patchset #1 id:1 of https://codereview.chromium.org/1746483002/ )
Reason for revert: http://crbug.com/590400 was fixed by https://codereview.chromium.org/1750513002 Original issue's description: > Revert of Pipe response_time from FetchManager to CacheStorage and ServiceWorkerURLRequestJob. (patchset #2 id:60001 of https://codereview.chromium.org/1738723002/ ) > > Reason for revert: > The newly added test FetchEvent_ResponseTime is ~33% flaky on Android, see http://crbug.com/590400. The error message is "[FATAL:weak_ptr.cc(20)] Check failed: sequence_checker_.CalledOnValidSequencedThread() || HasOneRef(). WeakPtrs must be invalidated on the same sequenced thread." > > BUG=590400 > > Original issue's description: > > Pipe response_time from FetchManager to CacheStorage and ServiceWorkerURLRequestJob. > > > > Currently response_time is used to identify the response in HttpCache when storing the V8 code cache to HttpCache. > > > > We are planning to support the V8 code caching in CacheStorage. > > To support this, we have to pipe the response_time from FetchManager to CacheStorage and ServiceWorkerURLRequestJob. > > Design doc: https://docs.google.com/document/d/1dVlgbXls-G65koU2vlmAXy1EVsoY9Z55jaEX7cZgfDA > > > > BUG=581613 > > > > Committed: https://crrev.com/3fbfbe6e7690dd2b169cfaaae2ad7ac89537d74b > > Cr-Commit-Position: refs/heads/master@{#377862} > > TBR=mkwst@chromium.org,dcheng@chromium.org,junov@chromium.org,nhiroki@chromium.org,horo@chromium.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=581613 > > Committed: https://crrev.com/21169106459125eb4c7b4133ce6d33482d865242 > Cr-Commit-Position: refs/heads/master@{#378040} TBR=mkwst@chromium.org,dcheng@chromium.org,junov@chromium.org,nhiroki@chromium.org,aelias@chromium.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=590400 Review URL: https://codereview.chromium.org/1750333002 Cr-Commit-Position: refs/heads/master@{#378484}
-rw-r--r--content/browser/cache_storage/cache_storage.proto1
-rw-r--r--content/browser/cache_storage/cache_storage_cache.cc7
-rw-r--r--content/browser/cache_storage/cache_storage_cache_unittest.cc14
-rw-r--r--content/browser/cache_storage/cache_storage_manager_unittest.cc2
-rw-r--r--content/browser/service_worker/embedded_worker_test_helper.cc8
-rw-r--r--content/browser/service_worker/service_worker_browsertest.cc26
-rw-r--r--content/browser/service_worker/service_worker_url_request_job.cc4
-rw-r--r--content/browser/service_worker/service_worker_url_request_job_unittest.cc12
-rw-r--r--content/common/service_worker/service_worker_messages.h1
-rw-r--r--content/common/service_worker/service_worker_types.cc6
-rw-r--r--content/common/service_worker/service_worker_types.h5
-rw-r--r--content/renderer/cache_storage/cache_storage_dispatcher.cc4
-rw-r--r--content/renderer/service_worker/service_worker_context_client.cc3
-rw-r--r--content/test/data/service_worker/fetch_event_response_via_cache.js28
-rw-r--r--third_party/WebKit/Source/modules/fetch/FetchManager.cpp1
-rw-r--r--third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp3
-rw-r--r--third_party/WebKit/Source/modules/fetch/FetchResponseData.h3
-rw-r--r--third_party/WebKit/Source/modules/fetch/Response.cpp1
-rw-r--r--third_party/WebKit/Source/platform/exported/WebServiceWorkerResponse.cpp12
-rw-r--r--third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h3
20 files changed, 118 insertions, 26 deletions
diff --git a/content/browser/cache_storage/cache_storage.proto b/content/browser/cache_storage/cache_storage.proto
index 807c1e5..07a61700c 100644
--- a/content/browser/cache_storage/cache_storage.proto
+++ b/content/browser/cache_storage/cache_storage.proto
@@ -42,6 +42,7 @@ message CacheResponse {
required ResponseType response_type = 3;
repeated CacheHeaderMap headers = 4;
optional string url = 5;
+ optional int64 response_time = 6;
}
message CacheMetadata {
diff --git a/content/browser/cache_storage/cache_storage_cache.cc b/content/browser/cache_storage/cache_storage_cache.cc
index 0c9a85a..1e114d9 100644
--- a/content/browser/cache_storage/cache_storage_cache.cc
+++ b/content/browser/cache_storage/cache_storage_cache.cc
@@ -773,7 +773,7 @@ void CacheStorageCache::Put(const CacheStorageBatchOperation& operation,
operation.response.status_text, operation.response.response_type,
operation.response.headers, operation.response.blob_uuid,
operation.response.blob_size, operation.response.stream_url,
- operation.response.error));
+ operation.response.error, operation.response.response_time));
scoped_ptr<storage::BlobDataHandle> blob_data_handle;
@@ -898,6 +898,8 @@ void CacheStorageCache::PutDidCreateEntry(
response_metadata->set_response_type(
WebResponseTypeToProtoResponseType(put_context->response->response_type));
response_metadata->set_url(put_context->response->url.spec());
+ response_metadata->set_response_time(
+ put_context->response->response_time.ToInternalValue());
for (ServiceWorkerHeaderMap::const_iterator it =
put_context->response->headers.begin();
it != put_context->response->headers.end(); ++it) {
@@ -1371,7 +1373,8 @@ void CacheStorageCache::PopulateResponseMetadata(
metadata.response().status_text(),
ProtoResponseTypeToWebResponseType(metadata.response().response_type()),
ServiceWorkerHeaderMap(), "", 0, GURL(),
- blink::WebServiceWorkerResponseErrorUnknown);
+ blink::WebServiceWorkerResponseErrorUnknown,
+ base::Time::FromInternalValue(metadata.response().response_time()));
for (int i = 0; i < metadata.response().headers_size(); ++i) {
const CacheHeaderMap header = metadata.response().headers(i);
diff --git a/content/browser/cache_storage/cache_storage_cache_unittest.cc b/content/browser/cache_storage/cache_storage_cache_unittest.cc
index d2ed1df..505f9bd 100644
--- a/content/browser/cache_storage/cache_storage_cache_unittest.cc
+++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc
@@ -328,18 +328,18 @@ class CacheStorageCacheTest : public testing::Test {
GURL("http://example.com/body.html"), 200, "OK",
blink::WebServiceWorkerResponseTypeDefault, headers,
blob_handle_->uuid(), expected_blob_data_.size(), GURL(),
- blink::WebServiceWorkerResponseErrorUnknown);
+ blink::WebServiceWorkerResponseErrorUnknown, base::Time());
body_response_with_query_ = ServiceWorkerResponse(
GURL("http://example.com/body.html?query=test"), 200, "OK",
blink::WebServiceWorkerResponseTypeDefault, headers,
blob_handle_->uuid(), expected_blob_data_.size(), GURL(),
- blink::WebServiceWorkerResponseErrorUnknown);
+ blink::WebServiceWorkerResponseErrorUnknown, base::Time());
no_body_response_ = ServiceWorkerResponse(
GURL("http://example.com/no_body.html"), 200, "OK",
blink::WebServiceWorkerResponseTypeDefault, headers, "", 0, GURL(),
- blink::WebServiceWorkerResponseErrorUnknown);
+ blink::WebServiceWorkerResponseErrorUnknown, base::Time());
}
scoped_ptr<ServiceWorkerFetchRequest> CopyFetchRequest(
@@ -1029,10 +1029,10 @@ TEST_P(CacheStorageCacheTestP, PutResponseType) {
TEST_F(CacheStorageCacheTest, CaselessServiceWorkerResponseHeaders) {
// CacheStorageCache depends on ServiceWorkerResponse having caseless
// headers so that it can quickly lookup vary headers.
- ServiceWorkerResponse response(GURL("http://www.example.com"), 200, "OK",
- blink::WebServiceWorkerResponseTypeDefault,
- ServiceWorkerHeaderMap(), "", 0, GURL(),
- blink::WebServiceWorkerResponseErrorUnknown);
+ ServiceWorkerResponse response(
+ GURL("http://www.example.com"), 200, "OK",
+ blink::WebServiceWorkerResponseTypeDefault, ServiceWorkerHeaderMap(), "",
+ 0, GURL(), blink::WebServiceWorkerResponseErrorUnknown, base::Time());
response.headers["content-type"] = "foo";
response.headers["Content-Type"] = "bar";
EXPECT_EQ("bar", response.headers["content-type"]);
diff --git a/content/browser/cache_storage/cache_storage_manager_unittest.cc b/content/browser/cache_storage/cache_storage_manager_unittest.cc
index 37a3e13..c06df8c 100644
--- a/content/browser/cache_storage/cache_storage_manager_unittest.cc
+++ b/content/browser/cache_storage/cache_storage_manager_unittest.cc
@@ -240,7 +240,7 @@ class CacheStorageManagerTest : public testing::Test {
ServiceWorkerResponse response(
url, 200, "OK", blink::WebServiceWorkerResponseTypeDefault,
ServiceWorkerHeaderMap(), blob_handle->uuid(), url.spec().size(),
- GURL(), blink::WebServiceWorkerResponseErrorUnknown);
+ GURL(), blink::WebServiceWorkerResponseErrorUnknown, base::Time());
CacheStorageBatchOperation operation;
operation.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT;
diff --git a/content/browser/service_worker/embedded_worker_test_helper.cc b/content/browser/service_worker/embedded_worker_test_helper.cc
index cac4286..21b99de 100644
--- a/content/browser/service_worker/embedded_worker_test_helper.cc
+++ b/content/browser/service_worker/embedded_worker_test_helper.cc
@@ -225,10 +225,10 @@ void EmbeddedWorkerTestHelper::OnFetchEvent(
SimulateSend(new ServiceWorkerHostMsg_FetchEventFinished(
embedded_worker_id, request_id,
SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE,
- ServiceWorkerResponse(GURL(), 200, "OK",
- blink::WebServiceWorkerResponseTypeDefault,
- ServiceWorkerHeaderMap(), std::string(), 0, GURL(),
- blink::WebServiceWorkerResponseErrorUnknown)));
+ ServiceWorkerResponse(
+ GURL(), 200, "OK", blink::WebServiceWorkerResponseTypeDefault,
+ ServiceWorkerHeaderMap(), std::string(), 0, GURL(),
+ blink::WebServiceWorkerResponseErrorUnknown, base::Time())));
}
void EmbeddedWorkerTestHelper::OnPushEvent(int embedded_worker_id,
diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc
index 97c29706..6129a10 100644
--- a/content/browser/service_worker/service_worker_browsertest.cc
+++ b/content/browser/service_worker/service_worker_browsertest.cc
@@ -14,6 +14,7 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
+#include "base/time/time.h"
#include "build/build_config.h"
#include "content/browser/fileapi/chrome_blob_storage_context.h"
#include "content/browser/service_worker/embedded_worker_instance.h"
@@ -948,6 +949,31 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchEvent_Response) {
}
IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest,
+ FetchEvent_ResponseTime) {
+ ServiceWorkerFetchEventResult result;
+ ServiceWorkerResponse response1;
+ ServiceWorkerResponse response2;
+ scoped_ptr<storage::BlobDataHandle> blob_data_handle;
+ const base::Time start_time(base::Time::Now());
+
+ RunOnIOThread(
+ base::Bind(&self::SetUpRegistrationOnIOThread, this,
+ "/service_worker/fetch_event_response_via_cache.js"));
+
+ FetchOnRegisteredWorker(&result, &response1, &blob_data_handle);
+ ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, result);
+ EXPECT_EQ(200, response1.status_code);
+ EXPECT_EQ("OK", response1.status_text);
+ EXPECT_TRUE(response1.response_time >= start_time);
+
+ FetchOnRegisteredWorker(&result, &response2, &blob_data_handle);
+ ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, result);
+ EXPECT_EQ(200, response2.status_code);
+ EXPECT_EQ("OK", response2.status_text);
+ EXPECT_EQ(response1.response_time, response2.response_time);
+}
+
+IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest,
FetchEvent_respondWithRejection) {
ServiceWorkerFetchEventResult result;
ServiceWorkerResponse response;
diff --git a/content/browser/service_worker/service_worker_url_request_job.cc b/content/browser/service_worker/service_worker_url_request_job.cc
index b5b97f2..092d72d 100644
--- a/content/browser/service_worker/service_worker_url_request_job.cc
+++ b/content/browser/service_worker/service_worker_url_request_job.cc
@@ -310,7 +310,8 @@ void ServiceWorkerURLRequestJob::OnBeforeNetworkStart(net::URLRequest* request,
void ServiceWorkerURLRequestJob::OnResponseStarted(net::URLRequest* request) {
// TODO(falken): Add Content-Length, Content-Type if they were not provided in
// the ServiceWorkerResponse.
- response_time_ = base::Time::Now();
+ if (response_time_.is_null())
+ response_time_ = base::Time::Now();
CommitResponseHeader();
}
@@ -663,6 +664,7 @@ void ServiceWorkerURLRequestJob::DidDispatchFetchEvent(
streaming_version_->AddStreamingURLRequestJob(this);
response_url_ = response.url;
service_worker_response_type_ = response.response_type;
+ response_time_ = response.response_time;
CreateResponseHeader(
response.status_code, response.status_text, response.headers);
load_timing_info_.receive_headers_end = base::TimeTicks::Now();
diff --git a/content/browser/service_worker/service_worker_url_request_job_unittest.cc b/content/browser/service_worker/service_worker_url_request_job_unittest.cc
index 3421141..39b0760 100644
--- a/content/browser/service_worker/service_worker_url_request_job_unittest.cc
+++ b/content/browser/service_worker/service_worker_url_request_job_unittest.cc
@@ -434,7 +434,7 @@ class ProviderDeleteHelper : public EmbeddedWorkerTestHelper {
ServiceWorkerResponse(
GURL(), 200, "OK", blink::WebServiceWorkerResponseTypeDefault,
ServiceWorkerHeaderMap(), std::string(), 0, GURL(),
- blink::WebServiceWorkerResponseErrorUnknown)));
+ blink::WebServiceWorkerResponseErrorUnknown, base::Time())));
}
private:
@@ -506,7 +506,7 @@ class BlobResponder : public EmbeddedWorkerTestHelper {
ServiceWorkerResponse(
GURL(), 200, "OK", blink::WebServiceWorkerResponseTypeDefault,
ServiceWorkerHeaderMap(), blob_uuid_, blob_size_, GURL(),
- blink::WebServiceWorkerResponseErrorUnknown)));
+ blink::WebServiceWorkerResponseErrorUnknown, base::Time())));
}
std::string blob_uuid_;
@@ -575,10 +575,10 @@ class StreamResponder : public EmbeddedWorkerTestHelper {
SimulateSend(new ServiceWorkerHostMsg_FetchEventFinished(
embedded_worker_id, request_id,
SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE,
- ServiceWorkerResponse(GURL(), 200, "OK",
- blink::WebServiceWorkerResponseTypeDefault,
- ServiceWorkerHeaderMap(), "", 0, stream_url_,
- blink::WebServiceWorkerResponseErrorUnknown)));
+ ServiceWorkerResponse(
+ GURL(), 200, "OK", blink::WebServiceWorkerResponseTypeDefault,
+ ServiceWorkerHeaderMap(), "", 0, stream_url_,
+ blink::WebServiceWorkerResponseErrorUnknown, base::Time())));
}
const GURL stream_url_;
diff --git a/content/common/service_worker/service_worker_messages.h b/content/common/service_worker/service_worker_messages.h
index 2bd68cd..c6ccfef 100644
--- a/content/common/service_worker/service_worker_messages.h
+++ b/content/common/service_worker/service_worker_messages.h
@@ -86,6 +86,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerResponse)
IPC_STRUCT_TRAITS_MEMBER(blob_size)
IPC_STRUCT_TRAITS_MEMBER(stream_url)
IPC_STRUCT_TRAITS_MEMBER(error)
+ IPC_STRUCT_TRAITS_MEMBER(response_time)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerObjectInfo)
diff --git a/content/common/service_worker/service_worker_types.cc b/content/common/service_worker/service_worker_types.cc
index 56437d0..93af174 100644
--- a/content/common/service_worker/service_worker_types.cc
+++ b/content/common/service_worker/service_worker_types.cc
@@ -71,7 +71,8 @@ ServiceWorkerResponse::ServiceWorkerResponse(
const std::string& blob_uuid,
uint64_t blob_size,
const GURL& stream_url,
- blink::WebServiceWorkerResponseError error)
+ blink::WebServiceWorkerResponseError error,
+ base::Time response_time)
: url(url),
status_code(status_code),
status_text(status_text),
@@ -80,7 +81,8 @@ ServiceWorkerResponse::ServiceWorkerResponse(
blob_uuid(blob_uuid),
blob_size(blob_size),
stream_url(stream_url),
- error(error) {}
+ error(error),
+ response_time(response_time) {}
ServiceWorkerResponse::ServiceWorkerResponse(
const ServiceWorkerResponse& other) = default;
diff --git a/content/common/service_worker/service_worker_types.h b/content/common/service_worker/service_worker_types.h
index e332f1c..b4d49b2 100644
--- a/content/common/service_worker/service_worker_types.h
+++ b/content/common/service_worker/service_worker_types.h
@@ -11,6 +11,7 @@
#include <string>
#include "base/strings/string_util.h"
+#include "base/time/time.h"
#include "content/common/content_export.h"
#include "content/public/common/referrer.h"
#include "content/public/common/request_context_frame_type.h"
@@ -160,7 +161,8 @@ struct CONTENT_EXPORT ServiceWorkerResponse {
const std::string& blob_uuid,
uint64_t blob_size,
const GURL& stream_url,
- blink::WebServiceWorkerResponseError error);
+ blink::WebServiceWorkerResponseError error,
+ base::Time response_time);
ServiceWorkerResponse(const ServiceWorkerResponse& other);
~ServiceWorkerResponse();
@@ -173,6 +175,7 @@ struct CONTENT_EXPORT ServiceWorkerResponse {
uint64_t blob_size;
GURL stream_url;
blink::WebServiceWorkerResponseError error;
+ base::Time response_time;
};
// Represents initialization info for a WebServiceWorker object.
diff --git a/content/renderer/cache_storage/cache_storage_dispatcher.cc b/content/renderer/cache_storage/cache_storage_dispatcher.cc
index 9091468..b20d19e 100644
--- a/content/renderer/cache_storage/cache_storage_dispatcher.cc
+++ b/content/renderer/cache_storage/cache_storage_dispatcher.cc
@@ -89,7 +89,8 @@ ServiceWorkerResponse ResponseFromWebResponse(
web_response.responseType(), headers,
base::UTF16ToASCII(base::StringPiece16(web_response.blobUUID())),
web_response.blobSize(), web_response.streamURL(),
- blink::WebServiceWorkerResponseErrorUnknown);
+ blink::WebServiceWorkerResponseErrorUnknown,
+ base::Time::FromInternalValue(web_response.responseTime()));
}
CacheStorageCacheQueryParams QueryParamsFromWebQueryParams(
@@ -646,6 +647,7 @@ void CacheStorageDispatcher::PopulateWebResponseFromResponse(
web_response->setStatus(response.status_code);
web_response->setStatusText(base::ASCIIToUTF16(response.status_text));
web_response->setResponseType(response.response_type);
+ web_response->setResponseTime(response.response_time.ToInternalValue());
for (const auto& i : response.headers) {
web_response->setHeader(base::ASCIIToUTF16(i.first),
diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc
index ba47847..78a49cd 100644
--- a/content/renderer/service_worker/service_worker_context_client.cc
+++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -534,7 +534,8 @@ void ServiceWorkerContextClient::didHandleFetchEvent(
web_response.url(), web_response.status(),
web_response.statusText().utf8(), web_response.responseType(), headers,
web_response.blobUUID().utf8(), web_response.blobSize(),
- web_response.streamURL(), web_response.error());
+ web_response.streamURL(), web_response.error(),
+ base::Time::FromInternalValue(web_response.responseTime()));
Send(new ServiceWorkerHostMsg_FetchEventFinished(
GetRoutingID(), request_id,
SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE,
diff --git a/content/test/data/service_worker/fetch_event_response_via_cache.js b/content/test/data/service_worker/fetch_event_response_via_cache.js
new file mode 100644
index 0000000..4fd03db
--- /dev/null
+++ b/content/test/data/service_worker/fetch_event_response_via_cache.js
@@ -0,0 +1,28 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+this.onfetch = function(event) {
+ var CACHE_NAME = 'cache_name';
+ var cache = undefined;
+ var url = event.request.url;
+ event.respondWith(
+ caches.open(CACHE_NAME)
+ .then(function(c) {
+ cache = c;
+ return cache.match(url);
+ })
+ .then(function(response) {
+ if (response)
+ return response;
+ var cloned_response = undefined;
+ return fetch(url)
+ .then(function(res) {
+ cloned_response = res.clone();
+ return cache.put(url, res);
+ })
+ .then(function() {
+ return cloned_response;
+ });
+ }));
+ };
diff --git a/third_party/WebKit/Source/modules/fetch/FetchManager.cpp b/third_party/WebKit/Source/modules/fetch/FetchManager.cpp
index a2feca2..d51c359 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchManager.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchManager.cpp
@@ -274,6 +274,7 @@ void FetchManager::Loader::didReceiveResponse(unsigned long, const ResourceRespo
responseData->headerList()->append(it.key, it.value);
responseData->setURL(response.url());
responseData->setMIMEType(response.mimeType());
+ responseData->setResponseTime(response.responseTime());
FetchResponseData* taintedResponse = nullptr;
diff --git a/third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp b/third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp
index 45d5dc2..09da38b 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp
@@ -168,6 +168,7 @@ FetchResponseData* FetchResponseData::clone(ExecutionContext* executionContext)
newResponse->m_statusMessage = m_statusMessage;
newResponse->m_headerList = m_headerList->clone();
newResponse->m_mimeType = m_mimeType;
+ newResponse->m_responseTime = m_responseTime;
switch (m_type) {
case BasicType:
@@ -216,6 +217,7 @@ void FetchResponseData::populateWebServiceWorkerResponse(WebServiceWorkerRespons
response.setStatus(status());
response.setStatusText(statusMessage());
response.setResponseType(fetchTypeToWebType(m_type));
+ response.setResponseTime(responseTime());
for (size_t i = 0; i < headerList()->size(); ++i) {
const FetchHeaderList::Header* header = headerList()->list()[i].get();
response.appendHeader(header->first, header->second);
@@ -227,6 +229,7 @@ FetchResponseData::FetchResponseData(Type type, unsigned short status, AtomicStr
, m_status(status)
, m_statusMessage(statusMessage)
, m_headerList(FetchHeaderList::create())
+ , m_responseTime(0)
{
}
diff --git a/third_party/WebKit/Source/modules/fetch/FetchResponseData.h b/third_party/WebKit/Source/modules/fetch/FetchResponseData.h
index 19605df..592ce2f 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchResponseData.h
+++ b/third_party/WebKit/Source/modules/fetch/FetchResponseData.h
@@ -50,11 +50,13 @@ public:
String mimeType() const;
BodyStreamBuffer* internalBuffer() const;
String internalMIMEType() const;
+ int64_t responseTime() const { return m_responseTime; }
void setURL(const KURL& url) { m_url = url; }
void setStatus(unsigned short status) { m_status = status; }
void setStatusMessage(AtomicString statusMessage) { m_statusMessage = statusMessage; }
void setMIMEType(const String& type) { m_mimeType = type; }
+ void setResponseTime(int64_t responseTime) { m_responseTime = responseTime; }
// If the type is Default, replaces |m_buffer|.
// If the type is Basic or CORS, replaces |m_buffer| and
@@ -79,6 +81,7 @@ private:
Member<FetchResponseData> m_internalResponse;
Member<BodyStreamBuffer> m_buffer;
String m_mimeType;
+ int64_t m_responseTime;
};
} // namespace blink
diff --git a/third_party/WebKit/Source/modules/fetch/Response.cpp b/third_party/WebKit/Source/modules/fetch/Response.cpp
index 63a6f53..60220e0 100644
--- a/third_party/WebKit/Source/modules/fetch/Response.cpp
+++ b/third_party/WebKit/Source/modules/fetch/Response.cpp
@@ -45,6 +45,7 @@ FetchResponseData* createFetchResponseDataFromWebResponse(ExecutionContext* exec
response->setURL(webResponse.url());
response->setStatus(webResponse.status());
response->setStatusMessage(webResponse.statusText());
+ response->setResponseTime(webResponse.responseTime());
for (HTTPHeaderMap::const_iterator i = webResponse.headers().begin(), end = webResponse.headers().end(); i != end; ++i) {
response->headerList()->append(i->key, i->value);
diff --git a/third_party/WebKit/Source/platform/exported/WebServiceWorkerResponse.cpp b/third_party/WebKit/Source/platform/exported/WebServiceWorkerResponse.cpp
index 49dd39e..89cb85a 100644
--- a/third_party/WebKit/Source/platform/exported/WebServiceWorkerResponse.cpp
+++ b/third_party/WebKit/Source/platform/exported/WebServiceWorkerResponse.cpp
@@ -17,6 +17,7 @@ public:
: status(0)
, responseType(WebServiceWorkerResponseTypeDefault)
, error(WebServiceWorkerResponseErrorUnknown)
+ , responseTime(0)
{
}
WebURL url;
@@ -27,6 +28,7 @@ public:
RefPtr<BlobDataHandle> blobDataHandle;
WebURL streamURL;
WebServiceWorkerResponseError error;
+ int64_t responseTime;
};
WebServiceWorkerResponse::WebServiceWorkerResponse()
@@ -170,4 +172,14 @@ WebServiceWorkerResponseError WebServiceWorkerResponse::error() const
return m_private->error;
}
+void WebServiceWorkerResponse::setResponseTime(int64_t time)
+{
+ m_private->responseTime = time;
+}
+
+int64_t WebServiceWorkerResponse::responseTime() const
+{
+ return m_private->responseTime;
+}
+
} // namespace blink
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h
index 74bdad6..30198279 100644
--- a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h
+++ b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h
@@ -76,6 +76,9 @@ public:
void setError(WebServiceWorkerResponseError);
WebServiceWorkerResponseError error() const;
+ void setResponseTime(int64_t);
+ int64_t responseTime() const;
+
#if INSIDE_BLINK
const HTTPHeaderMap& headers() const;