OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/glue/plugins/pepper_url_request_info.h" | 5 #include "webkit/glue/plugins/pepper_url_request_info.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/ppapi/c/pp_var.h" | 8 #include "third_party/ppapi/c/pp_var.h" |
9 #include "webkit/glue/plugins/pepper_plugin_module.h" | 9 #include "webkit/glue/plugins/pepper_plugin_module.h" |
10 #include "webkit/glue/plugins/pepper_resource_tracker.h" | |
11 #include "webkit/glue/plugins/pepper_string.h" | 10 #include "webkit/glue/plugins/pepper_string.h" |
12 #include "webkit/glue/plugins/pepper_var.h" | 11 #include "webkit/glue/plugins/pepper_var.h" |
13 | 12 |
14 namespace pepper { | 13 namespace pepper { |
15 | 14 |
16 namespace { | 15 namespace { |
17 | 16 |
18 PP_Resource Create(PP_Module module_id) { | 17 PP_Resource Create(PP_Module module_id) { |
19 PluginModule* module = PluginModule::FromPPModule(module_id); | 18 PluginModule* module = PluginModule::FromPPModule(module_id); |
20 if (!module) | 19 if (!module) |
21 return 0; | 20 return 0; |
22 | 21 |
23 URLRequestInfo* request = new URLRequestInfo(module); | 22 URLRequestInfo* request = new URLRequestInfo(module); |
24 request->AddRef(); // AddRef for the caller. | 23 request->AddRef(); // AddRef for the caller. |
25 | 24 |
26 return request->GetResource(); | 25 return request->GetResource(); |
27 } | 26 } |
28 | 27 |
29 bool IsURLRequestInfo(PP_Resource resource) { | 28 bool IsURLRequestInfo(PP_Resource resource) { |
30 return !!ResourceTracker::Get()->GetAsURLRequestInfo(resource).get(); | 29 return !!Resource::GetAs<URLRequestInfo>(resource).get(); |
31 } | 30 } |
32 | 31 |
33 bool SetProperty(PP_Resource request_id, | 32 bool SetProperty(PP_Resource request_id, |
34 PP_URLRequestProperty property, | 33 PP_URLRequestProperty property, |
35 PP_Var var) { | 34 PP_Var var) { |
36 scoped_refptr<URLRequestInfo> request( | 35 scoped_refptr<URLRequestInfo> request( |
37 ResourceTracker::Get()->GetAsURLRequestInfo(request_id)); | 36 Resource::GetAs<URLRequestInfo>(request_id)); |
38 if (!request.get()) | 37 if (!request.get()) |
39 return false; | 38 return false; |
40 | 39 |
41 if (var.type == PP_VarType_Bool) | 40 if (var.type == PP_VarType_Bool) |
42 return request->SetBooleanProperty(property, var.value.as_bool); | 41 return request->SetBooleanProperty(property, var.value.as_bool); |
43 | 42 |
44 if (var.type == PP_VarType_String) | 43 if (var.type == PP_VarType_String) |
45 return request->SetStringProperty(property, GetString(var)->value()); | 44 return request->SetStringProperty(property, GetString(var)->value()); |
46 | 45 |
47 return false; | 46 return false; |
48 } | 47 } |
49 | 48 |
50 bool AppendDataToBody(PP_Resource request_id, PP_Var var) { | 49 bool AppendDataToBody(PP_Resource request_id, PP_Var var) { |
51 scoped_refptr<URLRequestInfo> request( | 50 scoped_refptr<URLRequestInfo> request( |
52 ResourceTracker::Get()->GetAsURLRequestInfo(request_id)); | 51 Resource::GetAs<URLRequestInfo>(request_id)); |
53 if (!request.get()) | 52 if (!request.get()) |
54 return false; | 53 return false; |
55 | 54 |
56 String* data = GetString(var); | 55 String* data = GetString(var); |
57 if (!data) | 56 if (!data) |
58 return false; | 57 return false; |
59 | 58 |
60 return request->AppendDataToBody(data->value()); | 59 return request->AppendDataToBody(data->value()); |
61 } | 60 } |
62 | 61 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 NOTIMPLEMENTED(); // TODO(darin): Implement me! | 101 NOTIMPLEMENTED(); // TODO(darin): Implement me! |
103 return false; | 102 return false; |
104 } | 103 } |
105 | 104 |
106 bool URLRequestInfo::AppendDataToBody(const std::string& data) { | 105 bool URLRequestInfo::AppendDataToBody(const std::string& data) { |
107 NOTIMPLEMENTED(); // TODO(darin): Implement me! | 106 NOTIMPLEMENTED(); // TODO(darin): Implement me! |
108 return false; | 107 return false; |
109 } | 108 } |
110 | 109 |
111 } // namespace pepper | 110 } // namespace pepper |
OLD | NEW |