| 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/browser/chrome_plugin_host.h" | 5 #include "chrome/browser/chrome_plugin_host.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 12 #include "base/gfx/png_encoder.h" | 13 #include "base/gfx/png_encoder.h" |
| 13 #include "base/histogram.h" | 14 #include "base/histogram.h" |
| 14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 16 #include "base/perftimer.h" | 17 #include "base/perftimer.h" |
| 17 #include "base/singleton.h" | 18 #include "base/singleton.h" |
| 18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 19 #include "chrome/browser/browser_list.h" | 20 #include "chrome/browser/browser_list.h" |
| 20 #include "chrome/browser/chrome_plugin_browsing_context.h" | 21 #include "chrome/browser/chrome_plugin_browsing_context.h" |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 handler->request()->AppendBytesToUpload(bytes, bytes_len); | 631 handler->request()->AppendBytesToUpload(bytes, bytes_len); |
| 631 } | 632 } |
| 632 | 633 |
| 633 CPError STDCALL CPR_AppendFileToUpload(CPRequest* request, const char* filepath, | 634 CPError STDCALL CPR_AppendFileToUpload(CPRequest* request, const char* filepath, |
| 634 uint64 offset, uint64 length) { | 635 uint64 offset, uint64 length) { |
| 635 CHECK(ChromePluginLib::IsPluginThread()); | 636 CHECK(ChromePluginLib::IsPluginThread()); |
| 636 PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); | 637 PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); |
| 637 CHECK(handler); | 638 CHECK(handler); |
| 638 | 639 |
| 639 if (!length) length = kuint64max; | 640 if (!length) length = kuint64max; |
| 640 std::wstring wfilepath(UTF8ToWide(filepath)); | 641 FilePath path(FilePath::FromWStringHack(UTF8ToWide(filepath))); |
| 641 handler->request()->AppendFileRangeToUpload(wfilepath, offset, length); | 642 handler->request()->AppendFileRangeToUpload(path, offset, length); |
| 642 return CPERR_SUCCESS; | 643 return CPERR_SUCCESS; |
| 643 } | 644 } |
| 644 | 645 |
| 645 int STDCALL CPR_GetResponseInfo(CPRequest* request, CPResponseInfoType type, | 646 int STDCALL CPR_GetResponseInfo(CPRequest* request, CPResponseInfoType type, |
| 646 void* buf, uint32 buf_size) { | 647 void* buf, uint32 buf_size) { |
| 647 CHECK(ChromePluginLib::IsPluginThread()); | 648 CHECK(ChromePluginLib::IsPluginThread()); |
| 648 PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); | 649 PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); |
| 649 CHECK(handler); | 650 CHECK(handler); |
| 650 return PluginResponseUtils::GetResponseInfo( | 651 return PluginResponseUtils::GetResponseInfo( |
| 651 handler->request()->response_headers(), type, buf, buf_size); | 652 handler->request()->response_headers(), type, buf, buf_size); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 void CPHandleCommand(int command, CPCommandInterface* data, | 798 void CPHandleCommand(int command, CPCommandInterface* data, |
| 798 CPBrowsingContext context) { | 799 CPBrowsingContext context) { |
| 799 // Sadly if we try and pass context through, we seem to break cl's little | 800 // Sadly if we try and pass context through, we seem to break cl's little |
| 800 // brain trying to compile the Tuple3 ctor. This cast works. | 801 // brain trying to compile the Tuple3 ctor. This cast works. |
| 801 int32 context_as_int32 = static_cast<int32>(context); | 802 int32 context_as_int32 = static_cast<int32>(context); |
| 802 // Plugins can only be accessed on the IO thread. | 803 // Plugins can only be accessed on the IO thread. |
| 803 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 804 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
| 804 NewRunnableFunction(PluginCommandHandler::HandleCommand, | 805 NewRunnableFunction(PluginCommandHandler::HandleCommand, |
| 805 command, data, context_as_int32)); | 806 command, data, context_as_int32)); |
| 806 } | 807 } |
| OLD | NEW |