| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_url_response_info_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_url_response_info_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/c/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
| 9 #include "ppapi/shared_impl/var.h" | 9 #include "ppapi/shared_impl/var.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHTTPHeaderVisitor.
h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHTTPHeaderVisitor.
h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 redirect_url_ = response.httpHeaderField( | 67 redirect_url_ = response.httpHeaderField( |
| 68 WebString::fromUTF8("Location")).utf8(); | 68 WebString::fromUTF8("Location")).utf8(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 HeaderFlattener flattener; | 71 HeaderFlattener flattener; |
| 72 response.visitHTTPHeaderFields(&flattener); | 72 response.visitHTTPHeaderFields(&flattener); |
| 73 headers_ = flattener.buffer(); | 73 headers_ = flattener.buffer(); |
| 74 | 74 |
| 75 WebString file_path = response.downloadFilePath(); | 75 WebString file_path = response.downloadFilePath(); |
| 76 if (!file_path.isEmpty()) { | 76 if (!file_path.isEmpty()) { |
| 77 body_ = new PPB_FileRef_Impl(pp_instance(), | 77 body_ = PPB_FileRef_Impl::CreateExternal( |
| 78 webkit_glue::WebStringToFilePath(file_path)); | 78 pp_instance(), webkit_glue::WebStringToFilePath(file_path)); |
| 79 } | 79 } |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 PPB_URLResponseInfo_API* PPB_URLResponseInfo_Impl::AsPPB_URLResponseInfo_API() { | 83 PPB_URLResponseInfo_API* PPB_URLResponseInfo_Impl::AsPPB_URLResponseInfo_API() { |
| 84 return this; | 84 return this; |
| 85 } | 85 } |
| 86 | 86 |
| 87 PP_Var PPB_URLResponseInfo_Impl::GetProperty(PP_URLResponseProperty property) { | 87 PP_Var PPB_URLResponseInfo_Impl::GetProperty(PP_URLResponseProperty property) { |
| 88 PP_Module pp_module = ResourceHelper::GetPluginModule(this)->pp_module(); | 88 PP_Module pp_module = ResourceHelper::GetPluginModule(this)->pp_module(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 104 case PP_URLRESPONSEPROPERTY_HEADERS: | 104 case PP_URLRESPONSEPROPERTY_HEADERS: |
| 105 return StringVar::StringToPPVar(pp_module, headers_); | 105 return StringVar::StringToPPVar(pp_module, headers_); |
| 106 } | 106 } |
| 107 // The default is to return an undefined PP_Var. | 107 // The default is to return an undefined PP_Var. |
| 108 return PP_MakeUndefined(); | 108 return PP_MakeUndefined(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 PP_Resource PPB_URLResponseInfo_Impl::GetBodyAsFileRef() { | 111 PP_Resource PPB_URLResponseInfo_Impl::GetBodyAsFileRef() { |
| 112 if (!body_.get()) | 112 if (!body_.get()) |
| 113 return 0; | 113 return 0; |
| 114 body_->AddRef(); // AddRef for the caller. | |
| 115 return body_->GetReference(); | 114 return body_->GetReference(); |
| 116 } | 115 } |
| 117 | 116 |
| 118 } // namespace ppapi | 117 } // namespace ppapi |
| 119 } // namespace webkit | 118 } // namespace webkit |
| 120 | 119 |
| OLD | NEW |