Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Side by Side Diff: webkit/glue/plugins/pepper_url_response_info.cc

Issue 4310002: Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on W... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/plugins/pepper_url_request_info.cc ('k') | webkit/glue/plugins/pepper_url_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_response_info.h" 5 #include "webkit/glue/plugins/pepper_url_response_info.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 "third_party/WebKit/WebKit/chromium/public/WebHTTPHeaderVisitor.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebHTTPHeaderVisitor.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" 11 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
13 #include "webkit/glue/plugins/pepper_common.h"
13 #include "webkit/glue/plugins/pepper_file_ref.h" 14 #include "webkit/glue/plugins/pepper_file_ref.h"
14 #include "webkit/glue/plugins/pepper_var.h" 15 #include "webkit/glue/plugins/pepper_var.h"
15 #include "webkit/glue/webkit_glue.h" 16 #include "webkit/glue/webkit_glue.h"
16 17
17 using WebKit::WebHTTPHeaderVisitor; 18 using WebKit::WebHTTPHeaderVisitor;
18 using WebKit::WebString; 19 using WebKit::WebString;
19 using WebKit::WebURLResponse; 20 using WebKit::WebURLResponse;
20 21
21 namespace pepper { 22 namespace pepper {
22 23
23 namespace { 24 namespace {
24 25
25 class HeaderFlattener : public WebHTTPHeaderVisitor { 26 class HeaderFlattener : public WebHTTPHeaderVisitor {
26 public: 27 public:
27 const std::string& buffer() const { return buffer_; } 28 const std::string& buffer() const { return buffer_; }
28 29
29 virtual void visitHeader(const WebString& name, const WebString& value) { 30 virtual void visitHeader(const WebString& name, const WebString& value) {
30 if (!buffer_.empty()) 31 if (!buffer_.empty())
31 buffer_.append("\n"); 32 buffer_.append("\n");
32 buffer_.append(name.utf8()); 33 buffer_.append(name.utf8());
33 buffer_.append(": "); 34 buffer_.append(": ");
34 buffer_.append(value.utf8()); 35 buffer_.append(value.utf8());
35 } 36 }
36 37
37 private: 38 private:
38 std::string buffer_; 39 std::string buffer_;
39 }; 40 };
40 41
41 bool IsURLResponseInfo(PP_Resource resource) { 42 PP_Bool IsURLResponseInfo(PP_Resource resource) {
42 return !!Resource::GetAs<URLResponseInfo>(resource); 43 return BoolToPPBool(!!Resource::GetAs<URLResponseInfo>(resource));
43 } 44 }
44 45
45 PP_Var GetProperty(PP_Resource response_id, 46 PP_Var GetProperty(PP_Resource response_id,
46 PP_URLResponseProperty_Dev property) { 47 PP_URLResponseProperty_Dev property) {
47 scoped_refptr<URLResponseInfo> response( 48 scoped_refptr<URLResponseInfo> response(
48 Resource::GetAs<URLResponseInfo>(response_id)); 49 Resource::GetAs<URLResponseInfo>(response_id));
49 if (!response) 50 if (!response)
50 return PP_MakeUndefined(); 51 return PP_MakeUndefined();
51 52
52 return response->GetProperty(property); 53 return response->GetProperty(property);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 response.visitHTTPHeaderFields(&flattener); 110 response.visitHTTPHeaderFields(&flattener);
110 headers_ = flattener.buffer(); 111 headers_ = flattener.buffer();
111 112
112 WebString file_path = response.downloadFilePath(); 113 WebString file_path = response.downloadFilePath();
113 if (!file_path.isEmpty()) 114 if (!file_path.isEmpty())
114 body_ = new FileRef(module(), webkit_glue::WebStringToFilePath(file_path)); 115 body_ = new FileRef(module(), webkit_glue::WebStringToFilePath(file_path));
115 return true; 116 return true;
116 } 117 }
117 118
118 } // namespace pepper 119 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_url_request_info.cc ('k') | webkit/glue/plugins/pepper_url_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698