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

Side by Side Diff: ppapi/proxy/raw_var_data.cc

Issue 24196005: [PPAPI] ResourceVar now holds a pending renderer and browser host ID. (Closed) Base URL: http://git.chromium.org/chromium/src.git@pepper-resourcerawvardata
Patch Set: Rename set_pending_browser_host_id. Created 7 years, 2 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
« no previous file with comments | « ppapi/proxy/raw_var_data.h ('k') | ppapi/shared_impl/resource_var.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ppapi/proxy/raw_var_data.h" 5 #include "ppapi/proxy/raw_var_data.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 if (!m->ReadString(iter, &key)) 658 if (!m->ReadString(iter, &key))
659 return false; 659 return false;
660 if (!m->ReadUInt32(iter, &value)) 660 if (!m->ReadUInt32(iter, &value))
661 return false; 661 return false;
662 children_.push_back(make_pair(key, value)); 662 children_.push_back(make_pair(key, value));
663 } 663 }
664 return true; 664 return true;
665 } 665 }
666 666
667 // ResourceRawVarData ---------------------------------------------------------- 667 // ResourceRawVarData ----------------------------------------------------------
668 ResourceRawVarData::ResourceRawVarData() { 668 ResourceRawVarData::ResourceRawVarData()
669 } 669 : pp_resource_(0),
670 pending_renderer_host_id_(0),
671 pending_browser_host_id_(0) {}
670 672
671 ResourceRawVarData::~ResourceRawVarData() { 673 ResourceRawVarData::~ResourceRawVarData() {
672 } 674 }
673 675
674 PP_VarType ResourceRawVarData::Type() { 676 PP_VarType ResourceRawVarData::Type() {
675 return PP_VARTYPE_RESOURCE; 677 return PP_VARTYPE_RESOURCE;
676 } 678 }
677 679
678 bool ResourceRawVarData::Init(const PP_Var& var, PP_Instance /*instance*/) { 680 bool ResourceRawVarData::Init(const PP_Var& var, PP_Instance /*instance*/) {
679 DCHECK(var.type == PP_VARTYPE_RESOURCE); 681 DCHECK(var.type == PP_VARTYPE_RESOURCE);
680 ResourceVar* resource_var = ResourceVar::FromPPVar(var); 682 ResourceVar* resource_var = ResourceVar::FromPPVar(var);
681 if (!resource_var) 683 if (!resource_var)
682 return false; 684 return false;
683 pp_resource_ = resource_var->GetPPResource(); 685 pp_resource_ = resource_var->GetPPResource();
684 const IPC::Message* message = resource_var->GetCreationMessage(); 686 const IPC::Message* message = resource_var->GetCreationMessage();
685 if (message) 687 if (message)
686 creation_message_.reset(new IPC::Message(*message)); 688 creation_message_.reset(new IPC::Message(*message));
687 else 689 else
688 creation_message_.reset(); 690 creation_message_.reset();
691 pending_renderer_host_id_ = resource_var->GetPendingRendererHostId();
692 pending_browser_host_id_ = resource_var->GetPendingBrowserHostId();
689 initialized_ = true; 693 initialized_ = true;
690 return true; 694 return true;
691 } 695 }
692 696
693 PP_Var ResourceRawVarData::CreatePPVar(PP_Instance instance) { 697 PP_Var ResourceRawVarData::CreatePPVar(PP_Instance instance) {
694 // If pp_resource_ is NULL, it could be because we are on the plugin side and 698 // If pp_resource_ is NULL, it could be because we are on the plugin side and
695 // there is a pending resource host on the renderer. 699 // there is a pending resource host on the renderer.
696 // TODO(mgiuca): Create a plugin-side resource in this case. 700 // TODO(mgiuca): Create a plugin-side resource in this case.
697 // Currently, this should never occur. This will be needed when passing a 701 // Currently, this should never occur. This will be needed when passing a
698 // resource from the renderer to the plugin (http://crbug.com/177017). 702 // resource from the renderer to the plugin (http://crbug.com/177017).
699 DCHECK(pp_resource_); 703 DCHECK(pp_resource_);
700 704
701 return PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(pp_resource_); 705 return PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(pp_resource_);
702 } 706 }
703 707
704 void ResourceRawVarData::PopulatePPVar(const PP_Var& var, 708 void ResourceRawVarData::PopulatePPVar(const PP_Var& var,
705 const std::vector<PP_Var>& graph) { 709 const std::vector<PP_Var>& graph) {
706 } 710 }
707 711
708 void ResourceRawVarData::Write(IPC::Message* m, 712 void ResourceRawVarData::Write(IPC::Message* m,
709 const HandleWriter& handle_writer) { 713 const HandleWriter& handle_writer) {
710 m->WriteInt(static_cast<int>(pp_resource_)); 714 m->WriteInt(static_cast<int>(pp_resource_));
715 m->WriteInt(static_cast<int>(pending_renderer_host_id_));
716 m->WriteInt(static_cast<int>(pending_browser_host_id_));
dmichael (off chromium) 2013/09/25 21:25:15 These are already int, right? So no need to static
Matt Giuca 2013/09/25 23:57:00 Done. Good catch.
711 m->WriteBool(creation_message_); 717 m->WriteBool(creation_message_);
712 if (creation_message_) 718 if (creation_message_)
713 IPC::ParamTraits<IPC::Message>::Write(m, *creation_message_); 719 IPC::ParamTraits<IPC::Message>::Write(m, *creation_message_);
714 } 720 }
715 721
716 bool ResourceRawVarData::Read(PP_VarType type, 722 bool ResourceRawVarData::Read(PP_VarType type,
717 const IPC::Message* m, 723 const IPC::Message* m,
718 PickleIterator* iter) { 724 PickleIterator* iter) {
719 int value; 725 int value;
720 if (!m->ReadInt(iter, &value)) 726 if (!m->ReadInt(iter, &value))
721 return false; 727 return false;
722 pp_resource_ = static_cast<PP_Resource>(value); 728 pp_resource_ = static_cast<PP_Resource>(value);
729 if (!m->ReadInt(iter, &pending_renderer_host_id_))
730 return false;
731 if (!m->ReadInt(iter, &pending_browser_host_id_))
732 return false;
723 bool has_creation_message; 733 bool has_creation_message;
724 if (!m->ReadBool(iter, &has_creation_message)) 734 if (!m->ReadBool(iter, &has_creation_message))
725 return false; 735 return false;
726 if (has_creation_message) { 736 if (has_creation_message) {
727 creation_message_.reset(new IPC::Message()); 737 creation_message_.reset(new IPC::Message());
728 if (!IPC::ParamTraits<IPC::Message>::Read(m, iter, creation_message_.get())) 738 if (!IPC::ParamTraits<IPC::Message>::Read(m, iter, creation_message_.get()))
729 return false; 739 return false;
730 } else { 740 } else {
731 creation_message_.reset(); 741 creation_message_.reset();
732 } 742 }
733 return true; 743 return true;
734 } 744 }
735 745
736 } // namespace proxy 746 } // namespace proxy
737 } // namespace ppapi 747 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/raw_var_data.h ('k') | ppapi/shared_impl/resource_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698