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

Side by Side Diff: ppapi/thunk/enter.h

Issue 7706021: Convert FileRefImpl and URLRequestInfo to shared_impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
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 #ifndef PPAPI_THUNK_ENTER_H_ 5 #ifndef PPAPI_THUNK_ENTER_H_
6 #define PPAPI_THUNK_ENTER_H_ 6 #define PPAPI_THUNK_ENTER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "ppapi/c/pp_resource.h" 9 #include "ppapi/c/pp_resource.h"
10 #include "ppapi/proxy/interface_id.h" 10 #include "ppapi/proxy/interface_id.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 }; 91 };
92 92
93 // EnterResource --------------------------------------------------------------- 93 // EnterResource ---------------------------------------------------------------
94 94
95 template<typename ResourceT> 95 template<typename ResourceT>
96 class EnterResource { 96 class EnterResource {
97 public: 97 public:
98 EnterResource(PP_Resource resource, bool report_error) 98 EnterResource(PP_Resource resource, bool report_error)
99 : object_(NULL) { 99 : object_(NULL) {
100 Resource* base = 100 resource_ = TrackerBase::Get()->GetResourceTracker()->GetResource(resource);
101 TrackerBase::Get()->GetResourceTracker()->GetResource(resource); 101 if (resource_)
102 if (base) 102 object_ = resource_->GetAs<ResourceT>();
103 object_ = base->GetAs<ResourceT>();
104 // TODO(brettw) check error and if report_error is set, do something. 103 // TODO(brettw) check error and if report_error is set, do something.
105 } 104 }
106 ~EnterResource() {} 105 ~EnterResource() {}
107 106
108 bool succeeded() const { return !!object_; } 107 bool succeeded() const { return !!object_; }
109 bool failed() const { return !object_; } 108 bool failed() const { return !object_; }
110 109
111 ResourceT* object() { return object_; } 110 ResourceT* object() { return object_; }
111 Resource* resource() { return resource_; }
112 112
113 private: 113 private:
114 Resource* resource_;
114 ResourceT* object_; 115 ResourceT* object_;
115 116
116 DISALLOW_COPY_AND_ASSIGN(EnterResource); 117 DISALLOW_COPY_AND_ASSIGN(EnterResource);
117 }; 118 };
118 119
119 // Like EnterResource but assumes the lock is already held. 120 // Like EnterResource but assumes the lock is already held.
120 // TODO(brettw) actually implement locks, this is just a placeholder for now. 121 // TODO(brettw) actually implement locks, this is just a placeholder for now.
121 template<typename ResourceT> 122 template<typename ResourceT>
122 class EnterResourceNoLock : public EnterResource<ResourceT> { 123 class EnterResourceNoLock : public EnterResource<ResourceT> {
123 public: 124 public:
124 EnterResourceNoLock(PP_Resource resource, bool report_error) 125 EnterResourceNoLock(PP_Resource resource, bool report_error)
125 : EnterResource<ResourceT>(resource, report_error) { 126 : EnterResource<ResourceT>(resource, report_error) {
126 // TODO(brettw) assert the lock is held. 127 // TODO(brettw) assert the lock is held.
127 } 128 }
128 }; 129 };
129 130
130 } // namespace thunk 131 } // namespace thunk
131 } // namespace ppapi 132 } // namespace ppapi
132 133
133 #endif // PPAPI_THUNK_ENTER_H_ 134 #endif // PPAPI_THUNK_ENTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698