Commit 33c75092 authored by Alex Clarke's avatar Alex Clarke Committed by Commit Bot

Headless: Add GenericURLRequestJob::IsBrowserSideFetch

This lets a C++ embedder tell if a request was sent from the browser
or the renderer.

Bug: 
Change-Id: Id191dbc3003facc5125b17f38922b4d59ed67811
Reviewed-on: https://chromium-review.googlesource.com/746646Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512833}
parent 6506f071
......@@ -299,6 +299,12 @@ bool GenericURLRequestJob::IsAsync() const {
return true;
}
bool GenericURLRequestJob::IsBrowserSideFetch() const {
if (!request_resource_info_)
return false;
return request_resource_info_->GetFrameTreeNodeId() != -1;
}
namespace {
void CompletionCallback(int* dest, base::Closure* quit_closure, int value) {
*dest = value;
......
......@@ -56,6 +56,9 @@ class HEADLESS_EXPORT Request {
// Returns the size of the POST data, if any, from the net::URLRequest.
virtual uint64_t GetPostDataSize() const = 0;
// Returns true if the fetch was issues by the browser.
virtual bool IsBrowserSideFetch() const = 0;
enum class ResourceType {
MAIN_FRAME = 0,
SUB_FRAME = 1,
......@@ -159,6 +162,7 @@ class HEADLESS_EXPORT GenericURLRequestJob
uint64_t GetPostDataSize() const override;
ResourceType GetResourceType() const override;
bool IsAsync() const override;
bool IsBrowserSideFetch() const override;
private:
void PrepareCookies(const GURL& rewritten_url,
......
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