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

Side by Side Diff: ppapi/cpp/dev/printing_dev.cc

Issue 9381010: Convert resources to take an instance key instead of an Instance*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: USELESS PATCH TITLE Created 8 years, 9 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
« no previous file with comments | « ppapi/cpp/dev/printing_dev.h ('k') | ppapi/cpp/dev/resource_array_dev.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 (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 #include "ppapi/cpp/dev/printing_dev.h" 5 #include "ppapi/cpp/dev/printing_dev.h"
6 6
7 #include "ppapi/cpp/instance.h" 7 #include "ppapi/cpp/instance.h"
8 #include "ppapi/cpp/instance_handle.h"
8 #include "ppapi/cpp/module.h" 9 #include "ppapi/cpp/module.h"
9 #include "ppapi/cpp/module_impl.h" 10 #include "ppapi/cpp/module_impl.h"
10 11
11 namespace pp { 12 namespace pp {
12 13
13 namespace { 14 namespace {
14 15
15 static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE; 16 static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE;
16 17
17 uint32_t QuerySupportedFormats(PP_Instance instance) { 18 uint32_t QuerySupportedFormats(PP_Instance instance) {
18 void* object = 19 void* object =
19 pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); 20 Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
20 if (!object) 21 if (!object)
21 return 0; 22 return 0;
22 return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats(); 23 return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats();
23 } 24 }
24 25
25 int32_t Begin(PP_Instance instance, 26 int32_t Begin(PP_Instance instance,
26 const struct PP_PrintSettings_Dev* print_settings) { 27 const struct PP_PrintSettings_Dev* print_settings) {
27 void* object = 28 void* object =
28 pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); 29 Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
29 if (!object) 30 if (!object)
30 return 0; 31 return 0;
31 return static_cast<Printing_Dev*>(object)->PrintBegin(*print_settings); 32 return static_cast<Printing_Dev*>(object)->PrintBegin(*print_settings);
32 } 33 }
33 34
34 PP_Resource PrintPages(PP_Instance instance, 35 PP_Resource PrintPages(PP_Instance instance,
35 const struct PP_PrintPageNumberRange_Dev* page_ranges, 36 const struct PP_PrintPageNumberRange_Dev* page_ranges,
36 uint32_t page_range_count) { 37 uint32_t page_range_count) {
37 void* object = 38 void* object =
38 pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); 39 pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
(...skipping 23 matching lines...) Expand all
62 const PPP_Printing_Dev ppp_printing = { 63 const PPP_Printing_Dev ppp_printing = {
63 &QuerySupportedFormats, 64 &QuerySupportedFormats,
64 &Begin, 65 &Begin,
65 &PrintPages, 66 &PrintPages,
66 &End, 67 &End,
67 &IsScalingDisabled 68 &IsScalingDisabled
68 }; 69 };
69 70
70 } // namespace 71 } // namespace
71 72
72 Printing_Dev::Printing_Dev(Instance* instance) 73 Printing_Dev::Printing_Dev(const InstanceHandle& instance)
73 : associated_instance_(instance) { 74 : associated_instance_(instance) {
74 pp::Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing); 75 Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing);
75 associated_instance_->AddPerInstanceObject(kPPPPrintingInterface, this); 76 Instance::AddPerInstanceObject(instance, kPPPPrintingInterface, this);
76 } 77 }
77 78
78 Printing_Dev::~Printing_Dev() { 79 Printing_Dev::~Printing_Dev() {
79 associated_instance_->RemovePerInstanceObject(kPPPPrintingInterface, this); 80 Instance::RemovePerInstanceObject(associated_instance_,
81 kPPPPrintingInterface, this);
80 } 82 }
81 83
82 } // namespace pp 84 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/dev/printing_dev.h ('k') | ppapi/cpp/dev/resource_array_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698