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

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

Issue 6681028: Move the blob related code to content, and also move the blob messages to the... (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"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 r->set_width(w); 548 r->set_width(w);
549 r->set_height(h); 549 r->set_height(h);
550 return true; 550 return true;
551 } 551 }
552 552
553 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { 553 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) {
554 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(), 554 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(),
555 p.width(), p.height())); 555 p.width(), p.height()));
556 } 556 }
557 557
558 // Only the webkit_blob::BlobData ParamTraits<> definition needs this
559 // definition, so keep this in the implementation file so we can forward declare
560 // BlobData in the header.
561 template <>
562 struct ParamTraits<webkit_blob::BlobData::Item> {
563 typedef webkit_blob::BlobData::Item param_type;
564 static void Write(Message* m, const param_type& p) {
565 WriteParam(m, static_cast<int>(p.type()));
566 if (p.type() == webkit_blob::BlobData::TYPE_DATA) {
567 WriteParam(m, p.data());
568 } else if (p.type() == webkit_blob::BlobData::TYPE_FILE) {
569 WriteParam(m, p.file_path());
570 WriteParam(m, p.offset());
571 WriteParam(m, p.length());
572 WriteParam(m, p.expected_modification_time());
573 } else {
574 WriteParam(m, p.blob_url());
575 WriteParam(m, p.offset());
576 WriteParam(m, p.length());
577 }
578 }
579 static bool Read(const Message* m, void** iter, param_type* r) {
580 int type;
581 if (!ReadParam(m, iter, &type))
582 return false;
583 if (type == webkit_blob::BlobData::TYPE_DATA) {
584 std::string data;
585 if (!ReadParam(m, iter, &data))
586 return false;
587 r->SetToData(data);
588 } else if (type == webkit_blob::BlobData::TYPE_FILE) {
589 FilePath file_path;
590 uint64 offset, length;
591 base::Time expected_modification_time;
592 if (!ReadParam(m, iter, &file_path))
593 return false;
594 if (!ReadParam(m, iter, &offset))
595 return false;
596 if (!ReadParam(m, iter, &length))
597 return false;
598 if (!ReadParam(m, iter, &expected_modification_time))
599 return false;
600 r->SetToFile(file_path, offset, length, expected_modification_time);
601 } else {
602 DCHECK(type == webkit_blob::BlobData::TYPE_BLOB);
603 GURL blob_url;
604 uint64 offset, length;
605 if (!ReadParam(m, iter, &blob_url))
606 return false;
607 if (!ReadParam(m, iter, &offset))
608 return false;
609 if (!ReadParam(m, iter, &length))
610 return false;
611 r->SetToBlob(blob_url, offset, length);
612 }
613 return true;
614 }
615 static void Log(const param_type& p, std::string* l) {
616 l->append("<BlobData::Item>");
617 }
618 };
619
620 void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Write(
621 Message* m, const param_type& p) {
622 WriteParam(m, p.get() != NULL);
623 if (p) {
624 WriteParam(m, p->items());
625 WriteParam(m, p->content_type());
626 WriteParam(m, p->content_disposition());
627 }
628 }
629
630 bool ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Read(
631 const Message* m, void** iter, param_type* r) {
632 bool has_object;
633 if (!ReadParam(m, iter, &has_object))
634 return false;
635 if (!has_object)
636 return true;
637 std::vector<webkit_blob::BlobData::Item> items;
638 if (!ReadParam(m, iter, &items))
639 return false;
640 std::string content_type;
641 if (!ReadParam(m, iter, &content_type))
642 return false;
643 std::string content_disposition;
644 if (!ReadParam(m, iter, &content_disposition))
645 return false;
646 *r = new webkit_blob::BlobData;
647 (*r)->swap_items(&items);
648 (*r)->set_content_type(content_type);
649 (*r)->set_content_disposition(content_disposition);
650 return true;
651 }
652
653 void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Log(
654 const param_type& p, std::string* l) {
655 l->append("<webkit_blob::BlobData>");
656 }
657
558 } // namespace IPC 658 } // 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