diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-07 02:35:04 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-07 02:35:04 +0000 |
commit | fc6fb7fbf9aca6b58f8c99a08a6c376b95bbc1a3 (patch) | |
tree | ca9186ed7ddbeb19604b495430d9c9814df57471 /chrome_frame | |
parent | cfc076ec466fc48e91c309448c4e5be3467b42c7 (diff) | |
download | chromium_src-fc6fb7fbf9aca6b58f8c99a08a6c376b95bbc1a3.zip chromium_src-fc6fb7fbf9aca6b58f8c99a08a6c376b95bbc1a3.tar.gz chromium_src-fc6fb7fbf9aca6b58f8c99a08a6c376b95bbc1a3.tar.bz2 |
Basic wiring to enable downloads for CF's host browser network stack. A notable change here is that url automation job id's no longer exist and instead a request id is used. There's a 1 to 1 relation between a job and a request so this is more convenient.
Review URL: http://codereview.chromium.org/355036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/chrome_frame_activex_base.h | 7 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_automation.cc | 26 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_automation.h | 2 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_delegate.cc | 3 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_delegate.h | 1 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_npapi.cc | 2 | ||||
-rw-r--r-- | chrome_frame/plugin_url_request.cc | 5 | ||||
-rw-r--r-- | chrome_frame/test/net/test_automation_provider.cc | 8 | ||||
-rw-r--r-- | chrome_frame/test/net/test_automation_resource_message_filter.cc | 4 |
9 files changed, 45 insertions, 13 deletions
diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h index 85432ef..4941bba 100644 --- a/chrome_frame/chrome_frame_activex_base.h +++ b/chrome_frame/chrome_frame_activex_base.h @@ -462,7 +462,12 @@ END_MSG_MAP() virtual void OnRequestEnd(int tab_handle, int request_id, const URLRequestStatus& status) { - automation_client_->RemoveRequest(request_id, status.status(), true); + automation_client_->RemoveRequest(request_id, true); + } + + virtual void OnDownloadRequestInHost(int tab_handle, int request_id) { + DLOG(INFO) << "TODO: Let the host browser handle this download"; + automation_client_->RemoveRequest(request_id, false); } virtual void OnSetCookieAsync(int tab_handle, const GURL& url, diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index 0cafc87..6b9acb8 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -255,7 +255,9 @@ void ProxyFactory::CreateProxy(ProxyFactory::ProxyCacheEntry* entry, // Disable the "Whoa! Chrome has crashed." dialog, because that isn't very // useful for Chrome Frame users. +#ifndef NDEBUG command_line->AppendSwitch(switches::kNoErrorDialogs); +#endif command_line->AppendSwitch(switches::kEnableRendererAccessibility); @@ -668,7 +670,7 @@ void ChromeFrameAutomationClient::InstallExtensionComplete( const FilePath& crx_path, void* user_data, AutomationMsg_ExtensionResponseValues res) { - DCHECK(PlatformThread::CurrentId() == ui_thread_id_); + DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); if (chrome_frame_delegate_) { chrome_frame_delegate_->OnExtensionInstalled(crx_path, user_data, res); @@ -798,7 +800,7 @@ void ChromeFrameAutomationClient::LaunchComplete( void ChromeFrameAutomationClient::InitializeComplete( AutomationLaunchResult result) { - DCHECK(PlatformThread::CurrentId() == ui_thread_id_); + DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); std::string version = automation_server_->server_version(); if (result != AUTOMATION_SUCCESS) { @@ -981,12 +983,19 @@ bool ChromeFrameAutomationClient::Send(IPC::Message* msg) { } bool ChromeFrameAutomationClient::AddRequest(PluginUrlRequest* request) { + DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); + if (!request) { NOTREACHED(); return false; } - DCHECK(request_map_.end() == request_map_.find(request->id())); +#ifndef NDEBUG + RequestMap::const_iterator it = request_map_.find(request->id()); + scoped_refptr<PluginUrlRequest> other(request_map_.end() == it ? + NULL : (*it).second); + DCHECK(other.get() == NULL); +#endif request_map_[request->id()] = request; return true; } @@ -1002,12 +1011,13 @@ bool ChromeFrameAutomationClient::ReadRequest( } void ChromeFrameAutomationClient::RemoveRequest(PluginUrlRequest* request) { + DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); DCHECK(request_map_.end() != request_map_.find(request->id())); request_map_.erase(request->id()); } -void ChromeFrameAutomationClient::RemoveRequest( - int request_id, int reason, bool abort) { +void ChromeFrameAutomationClient::RemoveRequest(int request_id, bool abort) { + DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); PluginUrlRequest* request = LookupRequest(request_id); if (request) { if (abort) { @@ -1021,6 +1031,7 @@ void ChromeFrameAutomationClient::RemoveRequest( PluginUrlRequest* ChromeFrameAutomationClient::LookupRequest( int request_id) const { + DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); PluginUrlRequest* request = NULL; RequestMap::const_iterator it = request_map_.find(request_id); if (request_map_.end() != it) @@ -1030,13 +1041,14 @@ PluginUrlRequest* ChromeFrameAutomationClient::LookupRequest( bool ChromeFrameAutomationClient::IsValidRequest( PluginUrlRequest* request) const { + DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); bool is_valid = false; // if request is invalid then request->id() won't work // hence perform reverse map lookup for validity of the // request pointer. if (request) { for (RequestMap::const_iterator it = request_map_.begin(); - it != request_map_.end(); it++) { + it != request_map_.end(); it++) { if (request == (*it).second) { is_valid = true; break; @@ -1048,6 +1060,7 @@ bool ChromeFrameAutomationClient::IsValidRequest( } void ChromeFrameAutomationClient::CleanupRequests() { + DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); while (request_map_.size()) { PluginUrlRequest* request = request_map_.begin()->second; if (request) { @@ -1061,6 +1074,7 @@ void ChromeFrameAutomationClient::CleanupRequests() { } void ChromeFrameAutomationClient::CleanupAsyncRequests() { + DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); RequestMap::iterator index = request_map_.begin(); while (index != request_map_.end()) { PluginUrlRequest* request = (*index).second; diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h index 411fdb8..9d948a3 100644 --- a/chrome_frame/chrome_frame_automation.h +++ b/chrome_frame/chrome_frame_automation.h @@ -236,7 +236,7 @@ class ChromeFrameAutomationClient // URL request related bool ReadRequest(int request_id, int bytes_to_read); - void RemoveRequest(int request_id, int reason, bool abort); + void RemoveRequest(int request_id, bool abort); PluginUrlRequest* LookupRequest(int request_id) const; bool IsValidRequest(PluginUrlRequest* request) const; void CleanupRequests(); diff --git a/chrome_frame/chrome_frame_delegate.cc b/chrome_frame/chrome_frame_delegate.cc index 396d7a9..eb97186 100644 --- a/chrome_frame/chrome_frame_delegate.cc +++ b/chrome_frame/chrome_frame_delegate.cc @@ -22,6 +22,7 @@ bool ChromeFrameDelegateImpl::IsTabMessage(const IPC::Message& message, IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_RequestStart, ) IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_RequestRead, ) IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_RequestEnd, ) + IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_DownloadRequestInHost, ) IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_SetCookieAsync, ) IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_AttachExternalTab, ) IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_RequestGoToHistoryEntryOffset, ) @@ -62,6 +63,8 @@ void ChromeFrameDelegateImpl::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(AutomationMsg_RequestStart, OnRequestStart) IPC_MESSAGE_HANDLER(AutomationMsg_RequestRead, OnRequestRead) IPC_MESSAGE_HANDLER(AutomationMsg_RequestEnd, OnRequestEnd) + IPC_MESSAGE_HANDLER(AutomationMsg_DownloadRequestInHost, + OnDownloadRequestInHost) IPC_MESSAGE_HANDLER(AutomationMsg_SetCookieAsync, OnSetCookieAsync) IPC_MESSAGE_HANDLER(AutomationMsg_AttachExternalTab, OnAttachExternalTab) IPC_MESSAGE_HANDLER(AutomationMsg_RequestGoToHistoryEntryOffset, diff --git a/chrome_frame/chrome_frame_delegate.h b/chrome_frame/chrome_frame_delegate.h index bbdc99e..1742ad0 100644 --- a/chrome_frame/chrome_frame_delegate.h +++ b/chrome_frame/chrome_frame_delegate.h @@ -98,6 +98,7 @@ class ChromeFrameDelegateImpl : public ChromeFrameDelegate { int bytes_to_read) {} virtual void OnRequestEnd(int tab_handle, int request_id, const URLRequestStatus& status) {} + virtual void OnDownloadRequestInHost(int tab_handle, int request_id) {} virtual void OnSetCookieAsync(int tab_handle, const GURL& url, const std::string& cookie) {} virtual void OnAttachExternalTab(int tab_handle, intptr_t cookie, diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc index ec324e0..343a46d 100644 --- a/chrome_frame/chrome_frame_npapi.cc +++ b/chrome_frame/chrome_frame_npapi.cc @@ -683,7 +683,7 @@ void ChromeFrameNPAPI::OnRequestRead(int tab_handle, int request_id, void ChromeFrameNPAPI::OnRequestEnd(int tab_handle, int request_id, const URLRequestStatus& status) { - automation_client_->RemoveRequest(request_id, status.status(), true); + automation_client_->RemoveRequest(request_id, true); } void ChromeFrameNPAPI::OnSetCookieAsync(int tab_handle, const GURL& url, diff --git a/chrome_frame/plugin_url_request.cc b/chrome_frame/plugin_url_request.cc index 62a13f5..325ac44 100644 --- a/chrome_frame/plugin_url_request.cc +++ b/chrome_frame/plugin_url_request.cc @@ -8,7 +8,10 @@ #include "chrome_frame/np_browser_functions.h" PluginUrlRequest::PluginUrlRequest() - : request_handler_(NULL), tab_(0), remote_request_id_(0), post_data_len_(0), + : request_handler_(NULL), + tab_(0), + remote_request_id_(-1), + post_data_len_(0), status_(URLRequestStatus::IO_PENDING), frame_busting_enabled_(false) { } diff --git a/chrome_frame/test/net/test_automation_provider.cc b/chrome_frame/test/net/test_automation_provider.cc index 3a56aa4..f1a3b13 100644 --- a/chrome_frame/test/net/test_automation_provider.cc +++ b/chrome_frame/test/net/test_automation_provider.cc @@ -69,8 +69,14 @@ URLRequestJob* TestAutomationProvider::MaybeIntercept(URLRequest* request) { // and only intercept requests that belong to that thread. if (request->GetUserData(NULL) == NULL) { DCHECK(tab_handle_ != -1); + // We generate our own request id which is also what + // ResourceDispatcherHost does (well, the id is actually generated by + // ResourceDispatcher). Since these requests are divided into with + // and without userdata, we're OK. However, just to make debugging + // a little easier, we have a significantly higher start value. + static int new_id = 0x00100000; URLRequestAutomationJob* job = new URLRequestAutomationJob(request, - tab_handle_, filter_); + tab_handle_, new_id++, filter_); return job; } } diff --git a/chrome_frame/test/net/test_automation_resource_message_filter.cc b/chrome_frame/test/net/test_automation_resource_message_filter.cc index 32ef532..f7f00bc 100644 --- a/chrome_frame/test/net/test_automation_resource_message_filter.cc +++ b/chrome_frame/test/net/test_automation_resource_message_filter.cc @@ -25,8 +25,8 @@ bool TestAutomationResourceMessageFilter::OnMessageReceived( // for filter messages, send the message to the correct thread // for URL requests. bool handled = false; - int request_id = URLRequestAutomationJob::MayFilterMessage(message); - if (request_id) { + int request_id; + if (URLRequestAutomationJob::MayFilterMessage(message, &request_id)) { RequestMap::iterator it = requests_.find(request_id); if (it != requests_.end()) { handled = true; |