2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2006-2009 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.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_RESOURCE_REQUEST_JOB_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_RESOURCE_REQUEST_JOB_H_
|
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "include/cef_browser.h"
|
|
|
|
#include "include/cef_frame.h"
|
|
|
|
#include "include/cef_request_handler.h"
|
|
|
|
|
|
|
|
#include "net/cookies/cookie_monster.h"
|
|
|
|
#include "net/url_request/url_request_job.h"
|
|
|
|
|
|
|
|
namespace net {
|
|
|
|
class HttpResponseHeaders;
|
|
|
|
class URLRequest;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CefResourceRequestJobCallback;
|
|
|
|
|
|
|
|
class CefResourceRequestJob : public net::URLRequestJob {
|
|
|
|
public:
|
|
|
|
CefResourceRequestJob(net::URLRequest* request,
|
2012-08-29 00:26:35 +02:00
|
|
|
net::NetworkDelegate* network_delegate,
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefResourceHandler> handler);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefResourceRequestJob() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// net::URLRequestJob methods.
|
2014-11-12 20:25:15 +01:00
|
|
|
void Start() override;
|
|
|
|
void Kill() override;
|
2015-12-09 17:10:16 +01:00
|
|
|
int ReadRawData(net::IOBuffer* dest, int dest_size) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void GetResponseInfo(net::HttpResponseInfo* info) override;
|
2017-05-17 11:29:28 +02:00
|
|
|
void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override;
|
|
|
|
bool IsRedirectResponse(GURL* location, int* http_status_code) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
bool GetMimeType(std::string* mime_type) const override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
void SendHeaders();
|
|
|
|
|
|
|
|
// Used for sending cookies with the request.
|
|
|
|
void AddCookieHeaderAndStart();
|
|
|
|
void DoLoadCookies();
|
|
|
|
void CheckCookiePolicyAndLoad(const net::CookieList& cookie_list);
|
2013-03-12 21:23:24 +01:00
|
|
|
void OnCookiesLoaded(const std::string& cookie_line);
|
2012-04-03 03:34:16 +02:00
|
|
|
void DoStartTransaction();
|
|
|
|
void StartTransaction();
|
|
|
|
|
|
|
|
// Used for saving cookies returned as part of the response.
|
|
|
|
net::HttpResponseHeaders* GetResponseHeaders();
|
|
|
|
void SaveCookiesAndNotifyHeadersComplete();
|
|
|
|
void SaveNextCookie();
|
|
|
|
void OnCookieSaved(bool cookie_status);
|
|
|
|
void CookieHandled();
|
|
|
|
void FetchResponseCookies(std::vector<std::string>* cookies);
|
|
|
|
|
2015-12-04 19:59:14 +01:00
|
|
|
void DoneWithRequest();
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefResourceHandler> handler_;
|
2014-02-06 01:18:33 +01:00
|
|
|
bool done_;
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefResponse> response_;
|
|
|
|
GURL redirect_url_;
|
2016-01-06 20:20:54 +01:00
|
|
|
int64_t remaining_bytes_;
|
|
|
|
int64_t sent_bytes_;
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefRequest> cef_request_;
|
|
|
|
CefRefPtr<CefResourceRequestJobCallback> callback_;
|
|
|
|
scoped_refptr<net::HttpResponseHeaders> response_headers_;
|
|
|
|
std::vector<std::string> response_cookies_;
|
|
|
|
size_t response_cookies_save_index_;
|
2014-07-10 19:37:40 +02:00
|
|
|
base::Time request_start_time_;
|
|
|
|
base::TimeTicks receive_headers_end_;
|
|
|
|
|
|
|
|
// Must be the last member.
|
2012-04-03 03:34:16 +02:00
|
|
|
base::WeakPtrFactory<CefResourceRequestJob> weak_factory_;
|
|
|
|
|
|
|
|
friend class CefResourceRequestJobCallback;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefResourceRequestJob);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_RESOURCE_REQUEST_JOB_H_
|