diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-24 19:43:37 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-24 19:43:37 +0000 |
commit | 5826f3ea7caadda2945b5061b3d757fba9a9e359 (patch) | |
tree | af463753a6a92c90fa45470d9f1cf60d916b44e7 /webkit/glue/plugins/pepper_url_request_info.cc | |
parent | 584b46b245590ac92ca39ce93bed03d020b44534 (diff) | |
download | chromium_src-5826f3ea7caadda2945b5061b3d757fba9a9e359.zip chromium_src-5826f3ea7caadda2945b5061b3d757fba9a9e359.tar.gz chromium_src-5826f3ea7caadda2945b5061b3d757fba9a9e359.tar.bz2 |
Boilerplate implementation of the Pepper URL Loader API.
R=brettw
BUG=47222
TEST=none
Review URL: http://codereview.chromium.org/2859023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50756 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins/pepper_url_request_info.cc')
-rw-r--r-- | webkit/glue/plugins/pepper_url_request_info.cc | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/webkit/glue/plugins/pepper_url_request_info.cc b/webkit/glue/plugins/pepper_url_request_info.cc new file mode 100644 index 0000000..9eef1f9 --- /dev/null +++ b/webkit/glue/plugins/pepper_url_request_info.cc @@ -0,0 +1,111 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/glue/plugins/pepper_url_request_info.h" + +#include "base/logging.h" +#include "third_party/ppapi/c/pp_var.h" +#include "webkit/glue/plugins/pepper_plugin_module.h" +#include "webkit/glue/plugins/pepper_resource_tracker.h" +#include "webkit/glue/plugins/pepper_string.h" +#include "webkit/glue/plugins/pepper_var.h" + +namespace pepper { + +namespace { + +PP_Resource Create(PP_Module module_id) { + PluginModule* module = PluginModule::FromPPModule(module_id); + if (!module) + return 0; + + URLRequestInfo* request = new URLRequestInfo(module); + request->AddRef(); // AddRef for the caller. + + return request->GetResource(); +} + +bool IsURLRequestInfo(PP_Resource resource) { + return !!ResourceTracker::Get()->GetAsURLRequestInfo(resource).get(); +} + +bool SetProperty(PP_Resource request_id, + PP_URLRequestProperty property, + PP_Var var) { + scoped_refptr<URLRequestInfo> request( + ResourceTracker::Get()->GetAsURLRequestInfo(request_id)); + if (!request.get()) + return false; + + if (var.type == PP_VarType_Bool) + return request->SetBooleanProperty(property, var.value.as_bool); + + if (var.type == PP_VarType_String) + return request->SetStringProperty(property, GetString(var)->value()); + + return false; +} + +bool AppendDataToBody(PP_Resource request_id, PP_Var var) { + scoped_refptr<URLRequestInfo> request( + ResourceTracker::Get()->GetAsURLRequestInfo(request_id)); + if (!request.get()) + return false; + + String* data = GetString(var); + if (!data) + return false; + + return request->AppendDataToBody(data->value()); +} + +bool AppendFileToBody(PP_Resource request_id, + PP_Resource file_ref_id, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) { + NOTIMPLEMENTED(); // TODO(darin): Implement me! + return false; +} + +const PPB_URLRequestInfo ppb_urlrequestinfo = { + &Create, + &IsURLRequestInfo, + &SetProperty, + &AppendDataToBody, + &AppendFileToBody +}; + +} // namespace + +URLRequestInfo::URLRequestInfo(PluginModule* module) + : Resource(module) { +} + +URLRequestInfo::~URLRequestInfo() { +} + +// static +const PPB_URLRequestInfo* URLRequestInfo::GetInterface() { + return &ppb_urlrequestinfo; +} + +bool URLRequestInfo::SetBooleanProperty(PP_URLRequestProperty property, + bool value) { + NOTIMPLEMENTED(); // TODO(darin): Implement me! + return false; +} + +bool URLRequestInfo::SetStringProperty(PP_URLRequestProperty property, + const std::string& value) { + NOTIMPLEMENTED(); // TODO(darin): Implement me! + return false; +} + +bool URLRequestInfo::AppendDataToBody(const std::string& data) { + NOTIMPLEMENTED(); // TODO(darin): Implement me! + return false; +} + +} // namespace pepper |