OLD | NEW |
---|---|
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" |
11 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
12 #include "ppapi/proxy/file_system_resource.h" | |
13 #include "ppapi/proxy/plugin_dispatcher.h" | |
14 #include "ppapi/proxy/plugin_globals.h" | |
15 #include "ppapi/proxy/ppapi_messages.h" | |
12 #include "ppapi/proxy/ppapi_param_traits.h" | 16 #include "ppapi/proxy/ppapi_param_traits.h" |
17 #include "ppapi/proxy/resource_creation_proxy.h" | |
13 #include "ppapi/shared_impl/array_var.h" | 18 #include "ppapi/shared_impl/array_var.h" |
14 #include "ppapi/shared_impl/dictionary_var.h" | 19 #include "ppapi/shared_impl/dictionary_var.h" |
15 #include "ppapi/shared_impl/ppapi_globals.h" | 20 #include "ppapi/shared_impl/ppapi_globals.h" |
16 #include "ppapi/shared_impl/resource_var.h" | 21 #include "ppapi/shared_impl/resource_var.h" |
17 #include "ppapi/shared_impl/scoped_pp_var.h" | 22 #include "ppapi/shared_impl/scoped_pp_var.h" |
18 #include "ppapi/shared_impl/var.h" | 23 #include "ppapi/shared_impl/var.h" |
19 #include "ppapi/shared_impl/var_tracker.h" | 24 #include "ppapi/shared_impl/var_tracker.h" |
20 | 25 |
21 using std::make_pair; | 26 using std::make_pair; |
22 | 27 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 } else { | 62 } else { |
58 data->push_back(RawVarData::Create(var.type)); | 63 data->push_back(RawVarData::Create(var.type)); |
59 } | 64 } |
60 return data->size() - 1; | 65 return data->size() - 1; |
61 } | 66 } |
62 | 67 |
63 bool CanHaveChildren(PP_Var var) { | 68 bool CanHaveChildren(PP_Var var) { |
64 return var.type == PP_VARTYPE_ARRAY || var.type == PP_VARTYPE_DICTIONARY; | 69 return var.type == PP_VARTYPE_ARRAY || var.type == PP_VARTYPE_DICTIONARY; |
65 } | 70 } |
66 | 71 |
72 Connection GetConnectionForInstance(PP_Instance instance) { | |
73 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
74 return Connection(PluginGlobals::Get()->GetBrowserSender(), dispatcher); | |
dmichael (off chromium)
2013/10/22 16:04:28
I don't think this would do the right thing if it
Matt Giuca
2013/10/23 08:05:54
Done. (We reasoned that GetForInstance will always
| |
75 } | |
76 | |
67 } // namespace | 77 } // namespace |
68 | 78 |
69 // RawVarDataGraph ------------------------------------------------------------ | 79 // RawVarDataGraph ------------------------------------------------------------ |
70 RawVarDataGraph::RawVarDataGraph() { | 80 RawVarDataGraph::RawVarDataGraph() { |
71 } | 81 } |
72 | 82 |
73 RawVarDataGraph::~RawVarDataGraph() { | 83 RawVarDataGraph::~RawVarDataGraph() { |
74 } | 84 } |
75 | 85 |
76 // This function uses a stack-based DFS search to traverse the var graph. Each | 86 // This function uses a stack-based DFS search to traverse the var graph. Each |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 creation_message_.reset(new IPC::Message(*message)); | 698 creation_message_.reset(new IPC::Message(*message)); |
689 else | 699 else |
690 creation_message_.reset(); | 700 creation_message_.reset(); |
691 pending_renderer_host_id_ = resource_var->GetPendingRendererHostId(); | 701 pending_renderer_host_id_ = resource_var->GetPendingRendererHostId(); |
692 pending_browser_host_id_ = resource_var->GetPendingBrowserHostId(); | 702 pending_browser_host_id_ = resource_var->GetPendingBrowserHostId(); |
693 initialized_ = true; | 703 initialized_ = true; |
694 return true; | 704 return true; |
695 } | 705 } |
696 | 706 |
697 PP_Var ResourceRawVarData::CreatePPVar(PP_Instance instance) { | 707 PP_Var ResourceRawVarData::CreatePPVar(PP_Instance instance) { |
698 // If pp_resource_ is NULL, it could be because we are on the plugin side and | 708 // If we are on the plugin side, and the var is a pending resource host, |
699 // there is a pending resource host on the renderer. | 709 // create a plugin-side resource. A var is a pending resource host if it has a |
700 // TODO(mgiuca): Create a plugin-side resource in this case. | 710 // pp_resource of 0, and a non-null creation message. |
701 // Currently, this should never occur. This will be needed when passing a | 711 if (PpapiGlobals::Get()->IsPluginGlobals() && !pp_resource_ && |
702 // resource from the renderer to the plugin (http://crbug.com/177017). | 712 creation_message_) { |
703 DCHECK(pp_resource_); | 713 DCHECK(pending_renderer_host_id_); |
714 DCHECK(pending_browser_host_id_); | |
715 switch (creation_message_->type()) { | |
716 case PpapiPluginMsg_FileSystem_CreateFromPendingHost::ID: { | |
dmichael (off chromium)
2013/10/22 16:04:28
switch seems like an odd construct here. How about
Matt Giuca
2013/10/23 08:05:54
Why? This is just the first type of resource we ar
dmichael (off chromium)
2013/10/23 17:33:21
Oh, right, switch/case is fine. I wasn't thinking
| |
717 PP_FileSystemType file_system_type; | |
718 if (!UnpackMessage<PpapiPluginMsg_FileSystem_CreateFromPendingHost>( | |
719 *creation_message_, &file_system_type)) { | |
dmichael (off chromium)
2013/10/22 16:04:28
nit: indent is one space too far
Matt Giuca
2013/10/23 08:05:54
ClangFormat did it. It's indenting four spaces fro
| |
720 NOTREACHED() << "Invalid message of type " | |
721 "PpapiPluginMsg_FileSystem_CreateFromPendingHost"; | |
722 return PP_MakeNull(); | |
723 } | |
724 // Create a plugin-side resource and attach it to the host resource. | |
725 pp_resource_ = | |
726 (new FileSystemResource(GetConnectionForInstance(instance), | |
727 instance, | |
728 pending_renderer_host_id_, | |
729 pending_browser_host_id_, | |
730 file_system_type))->GetReference(); | |
731 DCHECK(pp_resource_); | |
raymes
2013/10/22 05:59:21
I think this DCHECK might be a bit uneeded. This c
Matt Giuca
2013/10/23 08:05:54
Well, the point of a DCHECK is to check for things
| |
732 break; | |
733 } | |
734 default: { | |
735 NOTREACHED() << "Creation message has unexpected type " | |
736 << creation_message_->type(); | |
737 return PP_MakeNull(); | |
738 } | |
739 } | |
740 } | |
704 | 741 |
705 return PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(pp_resource_); | 742 return PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(pp_resource_); |
706 } | 743 } |
707 | 744 |
708 void ResourceRawVarData::PopulatePPVar(const PP_Var& var, | 745 void ResourceRawVarData::PopulatePPVar(const PP_Var& var, |
709 const std::vector<PP_Var>& graph) { | 746 const std::vector<PP_Var>& graph) { |
710 } | 747 } |
711 | 748 |
712 void ResourceRawVarData::Write(IPC::Message* m, | 749 void ResourceRawVarData::Write(IPC::Message* m, |
713 const HandleWriter& handle_writer) { | 750 const HandleWriter& handle_writer) { |
(...skipping 24 matching lines...) Expand all Loading... | |
738 if (!IPC::ParamTraits<IPC::Message>::Read(m, iter, creation_message_.get())) | 775 if (!IPC::ParamTraits<IPC::Message>::Read(m, iter, creation_message_.get())) |
739 return false; | 776 return false; |
740 } else { | 777 } else { |
741 creation_message_.reset(); | 778 creation_message_.reset(); |
742 } | 779 } |
743 return true; | 780 return true; |
744 } | 781 } |
745 | 782 |
746 } // namespace proxy | 783 } // namespace proxy |
747 } // namespace ppapi | 784 } // namespace ppapi |
OLD | NEW |