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

Side by Side Diff: content/common/common_param_traits.cc

Issue 6682033: Move plugin messages to content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months 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 | « content/common/common_param_traits.h ('k') | content/common/content_message_generator.h » ('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) 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 "content/common/common_param_traits.h" 5 #include "content/common/common_param_traits.h"
6 6
7 #include "content/common/content_constants.h" 7 #include "content/common/content_constants.h"
8 #include "net/base/host_port_pair.h" 8 #include "net/base/host_port_pair.h"
9 #include "net/base/upload_data.h" 9 #include "net/base/upload_data.h"
10 #include "net/http/http_response_headers.h" 10 #include "net/http/http_response_headers.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
11 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
12 #include "webkit/glue/resource_loader_bridge.h" 13 #include "webkit/glue/resource_loader_bridge.h"
13 14
15 NPIdentifier_Param::NPIdentifier_Param()
16 : identifier() {
17 }
18
19 NPIdentifier_Param::~NPIdentifier_Param() {
20 }
21
22 NPVariant_Param::NPVariant_Param()
23 : type(NPVARIANT_PARAM_VOID),
24 bool_value(false),
25 int_value(0),
26 double_value(0),
27 npobject_routing_id(-1) {
28 }
29
30 NPVariant_Param::~NPVariant_Param() {
31 }
32
14 namespace IPC { 33 namespace IPC {
15 34
16 void ParamTraits<GURL>::Write(Message* m, const GURL& p) { 35 void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
17 m->WriteString(p.possibly_invalid_spec()); 36 m->WriteString(p.possibly_invalid_spec());
18 // TODO(brettw) bug 684583: Add encoding for query params. 37 // TODO(brettw) bug 684583: Add encoding for query params.
19 } 38 }
20 39
21 bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) { 40 bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) {
22 std::string s; 41 std::string s;
23 if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) { 42 if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) {
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 (*r)->set_content_type(content_type); 667 (*r)->set_content_type(content_type);
649 (*r)->set_content_disposition(content_disposition); 668 (*r)->set_content_disposition(content_disposition);
650 return true; 669 return true;
651 } 670 }
652 671
653 void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Log( 672 void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Log(
654 const param_type& p, std::string* l) { 673 const param_type& p, std::string* l) {
655 l->append("<webkit_blob::BlobData>"); 674 l->append("<webkit_blob::BlobData>");
656 } 675 }
657 676
677 void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) {
678 WriteParam(m, static_cast<int>(p.type));
679 if (p.type == NPVARIANT_PARAM_BOOL) {
680 WriteParam(m, p.bool_value);
681 } else if (p.type == NPVARIANT_PARAM_INT) {
682 WriteParam(m, p.int_value);
683 } else if (p.type == NPVARIANT_PARAM_DOUBLE) {
684 WriteParam(m, p.double_value);
685 } else if (p.type == NPVARIANT_PARAM_STRING) {
686 WriteParam(m, p.string_value);
687 } else if (p.type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID ||
688 p.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) {
689 // This is the routing id used to connect NPObjectProxy in the other
690 // process with NPObjectStub in this process or to identify the raw
691 // npobject pointer to be used in the callee process.
692 WriteParam(m, p.npobject_routing_id);
693 } else {
694 DCHECK(p.type == NPVARIANT_PARAM_VOID || p.type == NPVARIANT_PARAM_NULL);
695 }
696 }
697
698 bool ParamTraits<NPVariant_Param>::Read(const Message* m,
699 void** iter,
700 param_type* r) {
701 int type;
702 if (!ReadParam(m, iter, &type))
703 return false;
704
705 bool result = false;
706 r->type = static_cast<NPVariant_ParamEnum>(type);
707 if (r->type == NPVARIANT_PARAM_BOOL) {
708 result = ReadParam(m, iter, &r->bool_value);
709 } else if (r->type == NPVARIANT_PARAM_INT) {
710 result = ReadParam(m, iter, &r->int_value);
711 } else if (r->type == NPVARIANT_PARAM_DOUBLE) {
712 result = ReadParam(m, iter, &r->double_value);
713 } else if (r->type == NPVARIANT_PARAM_STRING) {
714 result = ReadParam(m, iter, &r->string_value);
715 } else if (r->type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID ||
716 r->type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) {
717 result = ReadParam(m, iter, &r->npobject_routing_id);
718 } else if ((r->type == NPVARIANT_PARAM_VOID) ||
719 (r->type == NPVARIANT_PARAM_NULL)) {
720 result = true;
721 } else {
722 NOTREACHED();
723 }
724
725 return result;
726 }
727
728 void ParamTraits<NPVariant_Param>::Log(const param_type& p, std::string* l) {
729 if (p.type == NPVARIANT_PARAM_BOOL) {
730 LogParam(p.bool_value, l);
731 } else if (p.type == NPVARIANT_PARAM_INT) {
732 LogParam(p.int_value, l);
733 } else if (p.type == NPVARIANT_PARAM_DOUBLE) {
734 LogParam(p.double_value, l);
735 } else if (p.type == NPVARIANT_PARAM_STRING) {
736 LogParam(p.string_value, l);
737 } else if (p.type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID ||
738 p.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) {
739 LogParam(p.npobject_routing_id, l);
740 }
741 }
742
743 void ParamTraits<NPIdentifier_Param>::Write(Message* m, const param_type& p) {
744 webkit_glue::SerializeNPIdentifier(p.identifier, m);
745 }
746
747 bool ParamTraits<NPIdentifier_Param>::Read(const Message* m,
748 void** iter,
749 param_type* r) {
750 return webkit_glue::DeserializeNPIdentifier(*m, iter, &r->identifier);
751 }
752
753 void ParamTraits<NPIdentifier_Param>::Log(const param_type& p, std::string* l) {
754 if (WebKit::WebBindings::identifierIsString(p.identifier)) {
755 NPUTF8* str = WebKit::WebBindings::utf8FromIdentifier(p.identifier);
756 l->append(str);
757 NPN_MemFree(str);
758 } else {
759 l->append(base::IntToString(
760 WebKit::WebBindings::intFromIdentifier(p.identifier)));
761 }
762 }
763
658 } // namespace IPC 764 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/common_param_traits.h ('k') | content/common/content_message_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698