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

Unified Diff: native_client_sdk/src/tests/nacl_io_test/fake_resource_manager.h

Issue 77423002: [NaCl SDK] Add URLLoader fake pepper interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/tests/nacl_io_test/fake_resource_manager.h
diff --git a/native_client_sdk/src/tests/nacl_io_test/fake_resource_manager.h b/native_client_sdk/src/tests/nacl_io_test/fake_resource_manager.h
index f545e910c6c2403e4c4b64b8a4fd039e36e9054a..33c44444c39a2b4ff686fe3ad54ac1d98f6ba11a 100644
--- a/native_client_sdk/src/tests/nacl_io_test/fake_resource_manager.h
+++ b/native_client_sdk/src/tests/nacl_io_test/fake_resource_manager.h
@@ -55,6 +55,14 @@ class FakeResourceTracker {
void Release() { sdk_util::AtomicAddFetch(&ref_count_, -1); }
int32_t ref_count() const { return ref_count_; }
+ // Give up ownership of this resource. It is the responsibility of the caller
+ // to delete this FakeResource.
+ FakeResource* Pass() {
+ FakeResource* result = resource_;
+ resource_ = NULL;
+ return result;
+ }
+
template <typename T>
T* resource() {
if (!CheckType(T::classname()))
@@ -63,6 +71,8 @@ class FakeResourceTracker {
return static_cast<T*>(resource_);
}
+ FakeResource* resource() { return resource_; }
+
const char* classname() const { return classname_; }
const char* file() const { return file_; }
int line() const { return line_; }
@@ -82,7 +92,11 @@ class FakeResourceTracker {
class FakeResource {
public:
FakeResource() {}
+ // Called when the resource is destroyed. For debugging purposes, this does
+ // not happen until the resource manager is destroyed.
virtual ~FakeResource() {}
+ // Called when the last reference to the resource is released.
+ virtual void Destroy() {}
private:
DISALLOW_COPY_AND_ASSIGN(FakeResource);
@@ -94,6 +108,6 @@ inline T* FakeResourceManager::Get(PP_Resource handle) {
}
#define CREATE_RESOURCE(MANAGER, TYPE, RESOURCE) \
- (MANAGER)->Create(RESOURCE, #TYPE, __FILE__, __LINE__)
+ (MANAGER)->Create((RESOURCE), #TYPE, __FILE__, __LINE__)
#endif // LIBRARIES_NACL_IO_TEST_FAKE_RESOURCE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698