summaryrefslogtreecommitdiffstats
path: root/chrome_frame/plugin_url_request.h
diff options
context:
space:
mode:
authorstoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-01 19:48:36 +0000
committerstoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-01 19:48:36 +0000
commit3eb07da6e868e49e28cb5a6d8a57037f2c45a20e (patch)
treeb9e05e275e38b176b1473e0f9e66075706ca238b /chrome_frame/plugin_url_request.h
parent55750b57e30ecc9f3657d1ebd08853e232ba4e23 (diff)
downloadchromium_src-3eb07da6e868e49e28cb5a6d8a57037f2c45a20e.zip
chromium_src-3eb07da6e868e49e28cb5a6d8a57037f2c45a20e.tar.gz
chromium_src-3eb07da6e868e49e28cb5a6d8a57037f2c45a20e.tar.bz2
TEST=new tests added.
Review URL: http://codereview.chromium.org/545093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37728 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/plugin_url_request.h')
-rw-r--r--chrome_frame/plugin_url_request.h137
1 files changed, 77 insertions, 60 deletions
diff --git a/chrome_frame/plugin_url_request.h b/chrome_frame/plugin_url_request.h
index 4993770..efd6741 100644
--- a/chrome_frame/plugin_url_request.h
+++ b/chrome_frame/plugin_url_request.h
@@ -18,43 +18,11 @@
#include "net/url_request/url_request_status.h"
class PluginUrlRequest;
+class PluginUrlRequestDelegate;
+class PluginUrlRequestManager;
-// Interface for a class that keeps a collection of outstanding
-// reqeusts and offers an outgoing channel.
-class PluginRequestHandler
- : public IPC::Message::Sender,
- public base::RefCountedThreadSafe<PluginRequestHandler> {
+class DECLSPEC_NOVTABLE PluginUrlRequestDelegate {
public:
- virtual bool AddRequest(PluginUrlRequest* request) = 0;
- virtual void RemoveRequest(PluginUrlRequest* request) = 0;
-};
-
-// A reference counting solution whose method's are compatible with
-// scoped_refptr and COM's IUnknown. Don't cast this object directly over to
-// IUnknown though since IUnknown's first method is QueryInterface.
-class UrlRequestReference {
- public:
- virtual unsigned long API_CALL AddRef() = 0; // NOLINT
- virtual unsigned long API_CALL Release() = 0; // NOLINT
-};
-
-class PluginUrlRequest : public UrlRequestReference {
- public:
- PluginUrlRequest();
- ~PluginUrlRequest();
-
- bool Initialize(PluginRequestHandler* handler, int tab,
- int remote_request_id, const std::string& url,
- const std::string& method, const std::string& referrer,
- const std::string& extra_headers,
- net::UploadData* upload_data,
- bool intercept_frame_options);
-
- // Called in response to automation IPCs
- virtual bool Start() = 0;
- virtual void Stop() = 0;
- virtual bool Read(int bytes_to_read) = 0;
-
// Persistent cookies are read from the host browser and passed off to Chrome
// These cookies are sent when we receive a response for every URL request
// initiated by Chrome. Ideally we should only send cookies for the top level
@@ -63,17 +31,77 @@ class PluginUrlRequest : public UrlRequestReference {
// Additionally cookies for a URL should be sent once for the page. This
// is not done now as it is difficult to track URLs, specifically if they
// are redirected, etc.
- void OnResponseStarted(const char* mime_type, const char* headers, int size,
- base::Time last_modified, const std::string& peristent_cookies,
- const std::string& redirect_url, int redirect_status);
+ virtual void OnResponseStarted(int request_id, const char* mime_type,
+ const char* headers, int size, base::Time last_modified,
+ const std::string& peristent_cookies, const std::string& redirect_url,
+ int redirect_status) = 0;
+ virtual void OnReadComplete(int request_id, const void* buffer, int len) = 0;
+ virtual void OnResponseEnd(int request_id, const URLRequestStatus& status) = 0;
+ protected:
+ PluginUrlRequestDelegate() {}
+ ~PluginUrlRequestDelegate() {}
+};
- void OnReadComplete(const void* buffer, int len);
- void OnResponseEnd(const URLRequestStatus& status);
+class DECLSPEC_NOVTABLE PluginUrlRequestManager {
+ public:
+ PluginUrlRequestManager() : delegate_(NULL), enable_frame_busting_(true) {}
+ virtual ~PluginUrlRequestManager() {}
+
+ void set_frame_busting(bool enable) {
+ enable_frame_busting_ = enable;
+ }
+
+ virtual void set_delegate(PluginUrlRequestDelegate* delegate) {
+ delegate_ = delegate;
+ }
+
+ virtual bool IsThreadSafe() = 0;
+
+ // These are called directly from Automation Client when network related
+ // automation messages are received from Chrome.
+ // Strip 'tab' handle and forward to the virtual methods implemented by
+ // derived classes.
+ void StartUrlRequest(int tab, int request_id,
+ const IPC::AutomationURLRequest& request_info) {
+ StartRequest(request_id, request_info);
+ }
+
+ void ReadUrlRequest(int tab, int request_id, int bytes_to_read) {
+ ReadRequest(request_id, bytes_to_read);
+ }
+
+ void EndUrlRequest(int tab, int request_id, const URLRequestStatus& s) {
+ EndRequest(request_id);
+ }
- PluginRequestHandler* request_handler() const {
- return request_handler_;
+ void StopAllRequests() {
+ StopAll();
}
+ protected:
+ PluginUrlRequestDelegate* delegate_;
+ bool enable_frame_busting_;
+
+ private:
+ virtual void StartRequest(int request_id,
+ const IPC::AutomationURLRequest& request_info) = 0;
+ virtual void ReadRequest(int request_id, int bytes_to_read) = 0;
+ virtual void EndRequest(int request_id) = 0;
+ virtual void StopAll() = 0;
+};
+
+// Used as base class. Holds Url request properties (url, method, referrer..)
+class PluginUrlRequest {
+ public:
+ PluginUrlRequest();
+ ~PluginUrlRequest();
+
+ bool Initialize(PluginUrlRequestDelegate* delegate,
+ int remote_request_id, const std::string& url, const std::string& method,
+ const std::string& referrer, const std::string& extra_headers,
+ net::UploadData* upload_data, bool enable_frame_busting_);
+
+ // Accessors.
int id() const {
return remote_request_id_;
}
@@ -86,10 +114,6 @@ class PluginUrlRequest : public UrlRequestReference {
return method_;
}
- void set_method(const std::string& new_method) {
- method_ = new_method;
- }
-
const std::string& referrer() const {
return referrer_;
}
@@ -102,6 +126,7 @@ class PluginUrlRequest : public UrlRequestReference {
return post_data_len_;
}
+ protected:
HRESULT get_upload_data(IStream** ret) {
DCHECK(ret);
if (!upload_data_.get())
@@ -111,26 +136,19 @@ class PluginUrlRequest : public UrlRequestReference {
return S_OK;
}
+ void set_url(const std::string& url) {
+ url_ = url;
+ }
+
void ClearPostData() {
upload_data_.Release();
post_data_len_ = 0;
}
- bool is_done() const {
- return (URLRequestStatus::IO_PENDING != status_);
- }
-
- void set_url(const std::string& url) {
- url_ = url;
- }
-
- protected:
void SendData();
- bool frame_busting_enabled_;
+ bool enable_frame_busting_;
- private:
- scoped_refptr<PluginRequestHandler> request_handler_;
- int tab_;
+ PluginUrlRequestDelegate* delegate_;
int remote_request_id_;
uint64 post_data_len_;
std::string url_;
@@ -138,7 +156,6 @@ class PluginUrlRequest : public UrlRequestReference {
std::string referrer_;
std::string extra_headers_;
ScopedComPtr<IStream> upload_data_;
- URLRequestStatus::Status status_;
};
#endif // CHROME_FRAME_PLUGIN_URL_REQUEST_H_