summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-29 07:54:18 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-29 07:54:18 +0000
commit3890cfff20f5407c0f5e7526cb5b8941d00901fa (patch)
treee59430650a82399d8c47ac90d5ecf0c71fc3b571 /ppapi/shared_impl
parent5d199d726c8b6ea5aa125c44b0c790672a2922c0 (diff)
downloadchromium_src-3890cfff20f5407c0f5e7526cb5b8941d00901fa.zip
chromium_src-3890cfff20f5407c0f5e7526cb5b8941d00901fa.tar.gz
chromium_src-3890cfff20f5407c0f5e7526cb5b8941d00901fa.tar.bz2
Adds a printing proxy and example. This adds a printing example.
Review URL: http://codereview.chromium.org/9455083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124149 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r--ppapi/shared_impl/api_id.h1
-rw-r--r--ppapi/shared_impl/resource_tracker.cc17
-rw-r--r--ppapi/shared_impl/resource_tracker.h8
3 files changed, 23 insertions, 3 deletions
diff --git a/ppapi/shared_impl/api_id.h b/ppapi/shared_impl/api_id.h
index f15f338..f886aab 100644
--- a/ppapi/shared_impl/api_id.h
+++ b/ppapi/shared_impl/api_id.h
@@ -58,6 +58,7 @@ enum ApiID {
API_ID_PPP_INSTANCE_PRIVATE,
API_ID_PPP_MESSAGING,
API_ID_PPP_MOUSE_LOCK,
+ API_ID_PPP_PRINTING,
API_ID_PPP_VIDEO_CAPTURE_DEV,
API_ID_PPP_VIDEO_DECODER_DEV,
diff --git a/ppapi/shared_impl/resource_tracker.cc b/ppapi/shared_impl/resource_tracker.cc
index 3b66db8..a889c59 100644
--- a/ppapi/shared_impl/resource_tracker.cc
+++ b/ppapi/shared_impl/resource_tracker.cc
@@ -1,9 +1,12 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/shared_impl/resource_tracker.h"
+#include "base/bind.h"
+#include "base/compiler_specific.h"
+#include "base/message_loop.h"
#include "ppapi/shared_impl/callback_tracker.h"
#include "ppapi/shared_impl/id_assignment.h"
#include "ppapi/shared_impl/ppapi_globals.h"
@@ -11,7 +14,9 @@
namespace ppapi {
-ResourceTracker::ResourceTracker() : last_resource_value_(0) {
+ResourceTracker::ResourceTracker()
+ : last_resource_value_(0),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
}
ResourceTracker::~ResourceTracker() {
@@ -67,6 +72,14 @@ void ResourceTracker::ReleaseResource(PP_Resource res) {
}
}
+void ResourceTracker::ReleaseResourceSoon(PP_Resource res) {
+ MessageLoop::current()->PostNonNestableTask(
+ FROM_HERE,
+ base::Bind(&ResourceTracker::ReleaseResource,
+ weak_ptr_factory_.GetWeakPtr(),
+ res));
+}
+
void ResourceTracker::DidCreateInstance(PP_Instance instance) {
// Due to the infrastructure of some tests, the instance is registered
// twice in a few cases. It would be nice not to do that and assert here
diff --git a/ppapi/shared_impl/resource_tracker.h b/ppapi/shared_impl/resource_tracker.h
index b585413..1c46bf5 100644
--- a/ppapi/shared_impl/resource_tracker.h
+++ b/ppapi/shared_impl/resource_tracker.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/hash_tables.h"
#include "base/memory/linked_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/shared_impl/ppapi_shared_export.h"
@@ -30,6 +31,9 @@ class PPAPI_SHARED_EXPORT ResourceTracker {
void AddRefResource(PP_Resource res);
void ReleaseResource(PP_Resource res);
+ // Releases a reference on the given resource once the message loop returns.
+ void ReleaseResourceSoon(PP_Resource res);
+
// Notifies the tracker that a new instance has been created. This must be
// called before creating any resources associated with the instance.
void DidCreateInstance(PP_Instance instance);
@@ -90,6 +94,8 @@ class PPAPI_SHARED_EXPORT ResourceTracker {
int32 last_resource_value_;
+ base::WeakPtrFactory<ResourceTracker> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ResourceTracker);
};