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

Side by Side Diff: ppapi/shared_impl/resource_var.cc

Issue 23809016: [PPAPI] ResourceVar now reference counts its PP_Resource in the plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix Windows compile. Created 7 years, 3 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/shared_impl/resource_var.h ('k') | ppapi/shared_impl/test_globals.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/shared_impl/resource_var.h" 5 #include "ppapi/shared_impl/resource_var.h"
6 6
7 #include "ppapi/shared_impl/ppapi_globals.h" 7 #include "ppapi/shared_impl/ppapi_globals.h"
8 #include "ppapi/shared_impl/var_tracker.h" 8 #include "ppapi/shared_impl/var_tracker.h"
9 9
10 namespace ppapi { 10 namespace ppapi {
11 11
12 ResourceVar::ResourceVar() : pp_resource_(0) {} 12 const IPC::Message* ResourceVar::GetCreationMessage() const {
13 13 return NULL;
14 ResourceVar::ResourceVar(PP_Resource pp_resource) : pp_resource_(pp_resource) {}
15
16 ResourceVar::ResourceVar(const IPC::Message& creation_message)
17 : pp_resource_(0),
18 creation_message_(creation_message) {}
19
20 ResourceVar::~ResourceVar() {}
21
22 bool ResourceVar::IsPending() const {
23 return pp_resource_ == 0 && creation_message_.type() != 0;
24 } 14 }
25 15
26 ResourceVar* ResourceVar::AsResourceVar() { 16 ResourceVar* ResourceVar::AsResourceVar() {
27 return this; 17 return this;
28 } 18 }
29 19
30 PP_VarType ResourceVar::GetType() const { 20 PP_VarType ResourceVar::GetType() const {
31 return PP_VARTYPE_RESOURCE; 21 return PP_VARTYPE_RESOURCE;
32 } 22 }
33 23
34 // static 24 // static
35 ResourceVar* ResourceVar::FromPPVar(PP_Var var) { 25 ResourceVar* ResourceVar::FromPPVar(PP_Var var) {
36 if (var.type != PP_VARTYPE_RESOURCE) 26 if (var.type != PP_VARTYPE_RESOURCE)
37 return NULL; 27 return NULL;
38 scoped_refptr<Var> var_object( 28 scoped_refptr<Var> var_object(
39 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); 29 PpapiGlobals::Get()->GetVarTracker()->GetVar(var));
40 if (!var_object.get()) 30 if (!var_object.get())
41 return NULL; 31 return NULL;
42 return var_object->AsResourceVar(); 32 return var_object->AsResourceVar();
43 } 33 }
44 34
35 ResourceVar::ResourceVar() {}
36
37 ResourceVar::~ResourceVar() {}
38
45 } // namespace ppapi 39 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/resource_var.h ('k') | ppapi/shared_impl/test_globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698