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

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

Issue 10560030: Add resource message call and reply infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/shared_impl/scoped_pp_var.h"
6
7 #include "ppapi/shared_impl/ppapi_globals.h"
8 #include "ppapi/shared_impl/var_tracker.h"
9
10 namespace ppapi {
11
12 namespace {
13
14 void CallAddRef(const PP_Var& v) {
15 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(v);
16 }
17
18 void CallRelease(const PP_Var& v) {
19 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(v);
20 }
21
22 } // namespace
23
24 ScopedPPVar::ScopedPPVar() : var_(PP_MakeUndefined()) {
25 }
26
27 ScopedPPVar::ScopedPPVar(const PP_Var& v) : var_(v) {
28 CallAddRef(var_);
29 }
30
31 ScopedPPVar::ScopedPPVar(const PassRef&, const PP_Var& v) : var_(v) {
32 }
bbudge 2012/06/19 20:40:31 I don't see how the input var loses its ref. Am I
33
34 ScopedPPVar::ScopedPPVar(const ScopedPPVar& other)
35 : var_(other.var_) {
36 CallAddRef(var_);
37 }
38
39 ScopedPPVar::~ScopedPPVar() {
40 CallRelease(var_);
41 }
42
43 ScopedPPVar& ScopedPPVar::operator=(const PP_Var& v) {
44 CallAddRef(v);
45 CallRelease(var_);
46 var_ = v;
47 return *this;
48 }
49
50 } // namespace ppapi
OLDNEW
« ppapi/proxy/resource_message_params.cc ('K') | « ppapi/shared_impl/scoped_pp_var.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698