| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/plugin/chrome_plugin_host.h" | 5 #include "chrome/plugin/chrome_plugin_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 10 #include "chrome/common/child_process.h" | 11 #include "chrome/common/child_process.h" |
| 11 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
| 12 #include "chrome/common/chrome_plugin_lib.h" | 13 #include "chrome/common/chrome_plugin_lib.h" |
| 13 #include "chrome/common/chrome_plugin_util.h" | 14 #include "chrome/common/chrome_plugin_util.h" |
| 14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/plugin_messages.h" | 16 #include "chrome/common/plugin_messages.h" |
| 16 #include "chrome/plugin/plugin_thread.h" | 17 #include "chrome/plugin/plugin_thread.h" |
| 17 #include "chrome/plugin/webplugin_proxy.h" | 18 #include "chrome/plugin/webplugin_proxy.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 load_flags_ = flags; | 121 load_flags_ = flags; |
| 121 } | 122 } |
| 122 void set_sync(bool sync) { | 123 void set_sync(bool sync) { |
| 123 sync_ = sync; | 124 sync_ = sync; |
| 124 } | 125 } |
| 125 void AppendDataToUpload(const char* bytes, int bytes_len) { | 126 void AppendDataToUpload(const char* bytes, int bytes_len) { |
| 126 upload_content_.push_back(net::UploadData::Element()); | 127 upload_content_.push_back(net::UploadData::Element()); |
| 127 upload_content_.back().SetToBytes(bytes, bytes_len); | 128 upload_content_.back().SetToBytes(bytes, bytes_len); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void AppendFileToUpload(const std::wstring &filepath) { | 131 void AppendFileToUpload(const FilePath &filepath) { |
| 131 AppendFileRangeToUpload(filepath, 0, kuint64max); | 132 AppendFileRangeToUpload(filepath, 0, kuint64max); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void AppendFileRangeToUpload(const std::wstring &filepath, | 135 void AppendFileRangeToUpload(const FilePath &filepath, |
| 135 uint64 offset, uint64 length) { | 136 uint64 offset, uint64 length) { |
| 136 upload_content_.push_back(net::UploadData::Element()); | 137 upload_content_.push_back(net::UploadData::Element()); |
| 137 upload_content_.back().SetToFilePathRange(filepath, offset, length); | 138 upload_content_.back().SetToFilePathRange(filepath, offset, length); |
| 138 } | 139 } |
| 139 | 140 |
| 140 CPError Start() { | 141 CPError Start() { |
| 141 bridge_.reset( | 142 bridge_.reset( |
| 142 PluginThread::current()->resource_dispatcher()->CreateBridge( | 143 PluginThread::current()->resource_dispatcher()->CreateBridge( |
| 143 cprequest_->method, | 144 cprequest_->method, |
| 144 GURL(cprequest_->url), | 145 GURL(cprequest_->url), |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 469 |
| 469 CPError STDCALL CPR_AppendFileToUpload(CPRequest* request, const char* filepath, | 470 CPError STDCALL CPR_AppendFileToUpload(CPRequest* request, const char* filepath, |
| 470 uint64 offset, uint64 length) { | 471 uint64 offset, uint64 length) { |
| 471 CHECK(ChromePluginLib::IsPluginThread()); | 472 CHECK(ChromePluginLib::IsPluginThread()); |
| 472 PluginRequestHandlerProxy* handler = | 473 PluginRequestHandlerProxy* handler = |
| 473 PluginRequestHandlerProxy::FromCPRequest(request); | 474 PluginRequestHandlerProxy::FromCPRequest(request); |
| 474 CHECK(handler); | 475 CHECK(handler); |
| 475 | 476 |
| 476 if (!length) length = kuint64max; | 477 if (!length) length = kuint64max; |
| 477 std::wstring wfilepath(UTF8ToWide(filepath)); | 478 std::wstring wfilepath(UTF8ToWide(filepath)); |
| 478 handler->AppendFileRangeToUpload(wfilepath, offset, length); | 479 handler->AppendFileRangeToUpload(FilePath::FromWStringHack(wfilepath), offset, |
| 480 length); |
| 479 return CPERR_SUCCESS; | 481 return CPERR_SUCCESS; |
| 480 } | 482 } |
| 481 | 483 |
| 482 int STDCALL CPR_GetResponseInfo(CPRequest* request, CPResponseInfoType type, | 484 int STDCALL CPR_GetResponseInfo(CPRequest* request, CPResponseInfoType type, |
| 483 void* buf, uint32 buf_size) { | 485 void* buf, uint32 buf_size) { |
| 484 CHECK(ChromePluginLib::IsPluginThread()); | 486 CHECK(ChromePluginLib::IsPluginThread()); |
| 485 PluginRequestHandlerProxy* handler = | 487 PluginRequestHandlerProxy* handler = |
| 486 PluginRequestHandlerProxy::FromCPRequest(request); | 488 PluginRequestHandlerProxy::FromCPRequest(request); |
| 487 CHECK(handler); | 489 CHECK(handler); |
| 488 return handler->GetResponseInfo(type, buf, buf_size); | 490 return handler->GetResponseInfo(type, buf, buf_size); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 | 613 |
| 612 response_funcs.size = sizeof(response_funcs); | 614 response_funcs.size = sizeof(response_funcs); |
| 613 response_funcs.received_redirect = CPRR_ReceivedRedirect; | 615 response_funcs.received_redirect = CPRR_ReceivedRedirect; |
| 614 response_funcs.start_completed = CPRR_StartCompleted; | 616 response_funcs.start_completed = CPRR_StartCompleted; |
| 615 response_funcs.read_completed = CPRR_ReadCompleted; | 617 response_funcs.read_completed = CPRR_ReadCompleted; |
| 616 response_funcs.upload_progress = CPRR_UploadProgress; | 618 response_funcs.upload_progress = CPRR_UploadProgress; |
| 617 } | 619 } |
| 618 | 620 |
| 619 return &browser_funcs; | 621 return &browser_funcs; |
| 620 } | 622 } |
| OLD | NEW |