summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-19 09:28:47 +0000
committerbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-19 09:28:47 +0000
commit2a64622057640041e14b6fb594517fd7b15ea868 (patch)
tree080f6d3c32eef3cd2dbfc409ab71d0a8bb09402c /chrome
parent89893c82d9cc50e616ac2a7cedb4f6cf7744c880 (diff)
downloadchromium_src-2a64622057640041e14b6fb594517fd7b15ea868.zip
chromium_src-2a64622057640041e14b6fb594517fd7b15ea868.tar.gz
chromium_src-2a64622057640041e14b6fb594517fd7b15ea868.tar.bz2
Added 'wasCached' parameter to webRequest API
Added a parameter that indicates whether a request was answered from the cache on disk. BUG=81262 TEST=no Review URL: http://codereview.chromium.org/7390006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_webrequest_api.cc4
-rw-r--r--chrome/browser/extensions/extension_webrequest_api_constants.cc1
-rw-r--r--chrome/browser/extensions/extension_webrequest_api_constants.h1
-rw-r--r--chrome/common/extensions/api/extension_api.json4
-rw-r--r--chrome/common/extensions/docs/experimental.webRequest.html272
-rw-r--r--chrome/test/data/extensions/api_test/webrequest/events/test.html24
6 files changed, 305 insertions, 1 deletions
diff --git a/chrome/browser/extensions/extension_webrequest_api.cc b/chrome/browser/extensions/extension_webrequest_api.cc
index a021fe3..b148573 100644
--- a/chrome/browser/extensions/extension_webrequest_api.cc
+++ b/chrome/browser/extensions/extension_webrequest_api.cc
@@ -507,6 +507,7 @@ void ExtensionWebRequestEventRouter::OnBeforeRedirect(
dict->SetInteger(keys::kStatusCodeKey, http_status_code);
if (!response_ip.empty())
dict->SetString(keys::kIpKey, response_ip);
+ dict->SetBoolean(keys::kFromCache, request->was_cached());
dict->SetDouble(keys::kTimeStampKey, time.ToDoubleT() * 1000);
if (extra_info_spec & ExtraInfoSpec::RESPONSE_HEADERS) {
dict->Set(keys::kResponseHeadersKey,
@@ -556,6 +557,7 @@ void ExtensionWebRequestEventRouter::OnResponseStarted(
dict->SetString(keys::kUrlKey, request->url().spec());
if (!response_ip.empty())
dict->SetString(keys::kIpKey, response_ip);
+ dict->SetBoolean(keys::kFromCache, request->was_cached());
dict->SetInteger(keys::kStatusCodeKey, response_code);
dict->SetDouble(keys::kTimeStampKey, time.ToDoubleT() * 1000);
if (extra_info_spec & ExtraInfoSpec::RESPONSE_HEADERS) {
@@ -607,6 +609,7 @@ void ExtensionWebRequestEventRouter::OnCompleted(
dict->SetInteger(keys::kStatusCodeKey, response_code);
if (!response_ip.empty())
dict->SetString(keys::kIpKey, response_ip);
+ dict->SetBoolean(keys::kFromCache, request->was_cached());
dict->SetDouble(keys::kTimeStampKey, time.ToDoubleT() * 1000);
if (extra_info_spec & ExtraInfoSpec::RESPONSE_HEADERS) {
dict->Set(keys::kResponseHeadersKey,
@@ -652,6 +655,7 @@ void ExtensionWebRequestEventRouter::OnErrorOccurred(
dict->SetString(keys::kUrlKey, request->url().spec());
if (!response_ip.empty())
dict->SetString(keys::kIpKey, response_ip);
+ dict->SetBoolean(keys::kFromCache, request->was_cached());
dict->SetString(keys::kErrorKey,
net::ErrorToString(request->status().os_error()));
dict->SetDouble(keys::kTimeStampKey, time.ToDoubleT() * 1000);
diff --git a/chrome/browser/extensions/extension_webrequest_api_constants.cc b/chrome/browser/extensions/extension_webrequest_api_constants.cc
index e627e18..2f49d37 100644
--- a/chrome/browser/extensions/extension_webrequest_api_constants.cc
+++ b/chrome/browser/extensions/extension_webrequest_api_constants.cc
@@ -7,6 +7,7 @@
namespace extension_webrequest_api_constants {
const char kErrorKey[] = "error";
+const char kFromCache[] = "fromCache";
const char kIpKey[] = "ip";
const char kMethodKey[] = "method";
const char kRedirectUrlKey[] = "redirectUrl";
diff --git a/chrome/browser/extensions/extension_webrequest_api_constants.h b/chrome/browser/extensions/extension_webrequest_api_constants.h
index bc3f5ba..6715cd7 100644
--- a/chrome/browser/extensions/extension_webrequest_api_constants.h
+++ b/chrome/browser/extensions/extension_webrequest_api_constants.h
@@ -12,6 +12,7 @@ namespace extension_webrequest_api_constants {
// Keys.
extern const char kErrorKey[];
+extern const char kFromCache[];
extern const char kIpKey[];
extern const char kMethodKey[];
extern const char kRedirectUrlKey[];
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 59d4909..b7cef60 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -4181,6 +4181,7 @@
"requestId": {"type": "string", "description": "The ID of the request."},
"url": {"type": "string"},
"ip": {"type": "string", "optional": true, "description": "The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address."},
+ "fromCache": {"type": "boolean", "description": "Indicates if this response was fetched from disk cache."},
"statusCode": {"type": "integer", "description": "Standard HTTP status code returned by the server."},
"timeStamp": {"type": "number", "description": "The time when the status line and response headers were received, in milliseconds since the epoch."},
"responseHeaders": {"$ref": "HttpHeaders", "optional": true, "description": "The HTTP response headers that were received along with this response."},
@@ -4219,6 +4220,7 @@
"requestId": {"type": "string", "description": "The ID of the request."},
"url": {"type": "string", "description": "The URL of the current request."},
"ip": {"type": "string", "optional": true, "description": "The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address."},
+ "fromCache": {"type": "boolean", "description": "Indicates if this response was fetched from disk cache."},
"statusCode": {"type": "integer", "description": "Standard HTTP status code returned by the server."},
"redirectUrl": {"type": "string", "description": "The new URL."},
"timeStamp": {"type": "number", "description": "The time when the browser was about to make the redirect, in milliseconds since the epoch."},
@@ -4258,6 +4260,7 @@
"requestId": {"type": "string", "description": "The ID of the request."},
"url": {"type": "string", "description": "The URL of the current request."},
"ip": {"type": "string", "optional": true, "description": "The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address."},
+ "fromCache": {"type": "boolean", "description": "Indicates if this response was fetched from disk cache."},
"statusCode": {"type": "integer", "description": "Standard HTTP status code returned by the server."},
"timeStamp": {"type": "number", "description": "The time when the response was received completely, in milliseconds since the epoch."},
"responseHeaders": {"$ref": "HttpHeaders", "optional": true, "description": "The HTTP response headers that were received along with this response."},
@@ -4296,6 +4299,7 @@
"requestId": {"type": "string", "description": "The ID of the request."},
"url": {"type": "string", "description": "The URL of the current request."},
"ip": {"type": "string", "optional": true, "description": "The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address."},
+ "fromCache": {"type": "boolean", "description": "Indicates if this response was fetched from disk cache."},
"error": {"type": "string", "description": "The error description. This string is <em>not</em> guaranteed to remain backwards compatible between releases. You must not parse and act based upon its content."},
"timeStamp": {"type": "number", "description": "The time when the error occurred, in milliseconds since the epoch."}
}
diff --git a/chrome/common/extensions/docs/experimental.webRequest.html b/chrome/common/extensions/docs/experimental.webRequest.html
index 716035d..7b8b063 100644
--- a/chrome/common/extensions/docs/experimental.webRequest.html
+++ b/chrome/common/extensions/docs/experimental.webRequest.html
@@ -795,6 +795,74 @@ unexpected results.
</div><div>
<div>
<dt>
+ <var>fromCache</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>boolean</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Indicates if this response was fetched from disk cache.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
<var>statusCode</var>
<em>
@@ -2912,6 +2980,74 @@ unexpected results.
</div><div>
<div>
<dt>
+ <var>fromCache</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>boolean</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Indicates if this response was fetched from disk cache.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
<var>statusCode</var>
<em>
@@ -3641,6 +3777,74 @@ unexpected results.
</div><div>
<div>
<dt>
+ <var>fromCache</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>boolean</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Indicates if this response was fetched from disk cache.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
<var>error</var>
<em>
@@ -4157,6 +4361,74 @@ unexpected results.
</div><div>
<div>
<dt>
+ <var>fromCache</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>boolean</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Indicates if this response was fetched from disk cache.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
<var>statusCode</var>
<em>
diff --git a/chrome/test/data/extensions/api_test/webrequest/events/test.html b/chrome/test/data/extensions/api_test/webrequest/events/test.html
index bbddc9b..3548fd8 100644
--- a/chrome/test/data/extensions/api_test/webrequest/events/test.html
+++ b/chrome/test/data/extensions/api_test/webrequest/events/test.html
@@ -239,7 +239,8 @@ runTests([
event: "onResponseStarted",
details: {
url: getURL("simpleLoad/a.html"),
- statusCode: 200
+ statusCode: 200,
+ fromCache: false
// Request to chrome-extension:// url has no IP.
}
},
@@ -248,6 +249,7 @@ runTests([
details: {
url: getURL("simpleLoad/a.html"),
statusCode: 200,
+ fromCache: false
// Request to chrome-extension:// url has no IP.
}
},
@@ -293,6 +295,7 @@ runTests([
statusCode: 301,
responseHeadersExist: true,
ip: "127.0.0.1",
+ fromCache: false,
statusLine: "HTTP/1.0 301 Moved Permanently"
}
},
@@ -326,6 +329,7 @@ runTests([
statusCode: 200,
responseHeadersExist: true,
ip: "127.0.0.1",
+ fromCache: false,
statusLine: "HTTP/1.0 200 OK",
}
},
@@ -335,6 +339,7 @@ runTests([
url: URL_HTTP_SIMPLE_LOAD,
statusCode: 200,
ip: "127.0.0.1",
+ fromCache: false,
responseHeadersExist: true,
statusLine: "HTTP/1.0 200 OK"
}
@@ -387,6 +392,7 @@ runTests([
event: "onResponseStarted",
details: {
url: getURL("complexLoad/a.html"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -395,6 +401,7 @@ runTests([
event: "onResponseStarted",
details: {
url: getURL("complexLoad/b.html"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -403,6 +410,7 @@ runTests([
event: "onResponseStarted",
details: {
url: getURL("complexLoad/b.jpg"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -411,6 +419,7 @@ runTests([
event: "onCompleted",
details: {
url: getURL("complexLoad/a.html"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -419,6 +428,7 @@ runTests([
event: "onCompleted",
details: {
url: getURL("complexLoad/b.html"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -427,6 +437,7 @@ runTests([
event: "onCompleted",
details: {
url: getURL("complexLoad/b.jpg"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -464,6 +475,7 @@ runTests([
event: "onErrorOccurred",
details: {
url: getURL("complexLoad/a.html"),
+ fromCache: false,
error: "net::ERR_EMPTY_RESPONSE"
// Request to chrome-extension:// url has no IP.
}
@@ -499,6 +511,7 @@ runTests([
event: "onErrorOccurred",
details: {
url: getURL("complexLoad/a.html"),
+ fromCache: false,
error: "net::ERR_ABORTED"
// Request to chrome-extension:// url has no IP.
}
@@ -516,6 +529,7 @@ runTests([
event: "onResponseStarted",
details: {
url: getURL("simpleLoad/a.html"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -524,6 +538,7 @@ runTests([
event: "onCompleted",
details: {
url: getURL("simpleLoad/a.html"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -565,6 +580,7 @@ runTests([
event: "onResponseStarted",
details: {
url: getURL("complexLoad/a.html"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -573,6 +589,7 @@ runTests([
event: "onResponseStarted",
details: {
url: getURL("complexLoad/b.jpg"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -581,6 +598,7 @@ runTests([
event: "onCompleted",
details: {
url: getURL("complexLoad/a.html"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -589,6 +607,7 @@ runTests([
event: "onCompleted",
details: {
url: getURL("complexLoad/b.jpg"),
+ fromCache: false,
statusCode: 200
// Request to chrome-extension:// url has no IP.
}
@@ -628,6 +647,7 @@ runTests([
event: "onErrorOccurred",
details: {
url: getURL("does_not_exist.html"),
+ fromCache: false,
error: "net::ERR_FILE_NOT_FOUND",
// Request to chrome-extension:// url has no IP.
}
@@ -671,6 +691,7 @@ runTests([
event: "onResponseStarted",
details: {
url: URL_ECHO_USER_AGENT,
+ fromCache: false,
statusCode: 200,
ip: "127.0.0.1"
}
@@ -679,6 +700,7 @@ runTests([
event: "onCompleted",
details: {
url: URL_ECHO_USER_AGENT,
+ fromCache: false,
statusCode: 200,
ip: "127.0.0.1"
}