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

Side by Side Diff: ppapi/cpp/dev/find_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, 10 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/find_dev.h ('k') | ppapi/cpp/dev/font_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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/find_dev.h" 5 #include "ppapi/cpp/dev/find_dev.h"
6 6
7 #include "ppapi/c/dev/ppb_find_dev.h" 7 #include "ppapi/c/dev/ppb_find_dev.h"
8 #include "ppapi/cpp/instance.h" 8 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/module.h" 9 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/module_impl.h" 10 #include "ppapi/cpp/module_impl.h"
11 11
12 namespace pp { 12 namespace pp {
13 13
14 namespace { 14 namespace {
15 15
16 template <> const char* interface_name<PPB_Find_Dev>() { 16 template <> const char* interface_name<PPB_Find_Dev>() {
17 return PPB_FIND_DEV_INTERFACE; 17 return PPB_FIND_DEV_INTERFACE;
18 } 18 }
19 19
20 static const char kPPPFindInterface[] = PPP_FIND_DEV_INTERFACE; 20 static const char kPPPFindInterface[] = PPP_FIND_DEV_INTERFACE;
21 21
22 PP_Bool StartFind(PP_Instance instance, 22 PP_Bool StartFind(PP_Instance instance,
23 const char* text, 23 const char* text,
24 PP_Bool case_sensitive) { 24 PP_Bool case_sensitive) {
25 void* object = 25 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface);
26 pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface);
27 if (!object) 26 if (!object)
28 return PP_FALSE; 27 return PP_FALSE;
29 bool return_value = static_cast<Find_Dev*>(object)->StartFind( 28 bool return_value = static_cast<Find_Dev*>(object)->StartFind(
30 text, PP_ToBool(case_sensitive)); 29 text, PP_ToBool(case_sensitive));
31 return PP_FromBool(return_value); 30 return PP_FromBool(return_value);
32 } 31 }
33 32
34 void SelectFindResult(PP_Instance instance, PP_Bool forward) { 33 void SelectFindResult(PP_Instance instance, PP_Bool forward) {
35 void* object = 34 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface);
36 pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface);
37 if (object) 35 if (object)
38 static_cast<Find_Dev*>(object)->SelectFindResult(PP_ToBool(forward)); 36 static_cast<Find_Dev*>(object)->SelectFindResult(PP_ToBool(forward));
39 } 37 }
40 38
41 void StopFind(PP_Instance instance) { 39 void StopFind(PP_Instance instance) {
42 void* object = 40 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface);
43 pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface);
44 if (object) 41 if (object)
45 static_cast<Find_Dev*>(object)->StopFind(); 42 static_cast<Find_Dev*>(object)->StopFind();
46 } 43 }
47 44
48 const PPP_Find_Dev ppp_find = { 45 const PPP_Find_Dev ppp_find = {
49 &StartFind, 46 &StartFind,
50 &SelectFindResult, 47 &SelectFindResult,
51 &StopFind 48 &StopFind
52 }; 49 };
53 50
54 } // namespace 51 } // namespace
55 52
56 Find_Dev::Find_Dev(Instance* instance) : associated_instance_(instance) { 53 Find_Dev::Find_Dev(const InstanceHandle& instance)
57 pp::Module::Get()->AddPluginInterface(kPPPFindInterface, &ppp_find); 54 : associated_instance_(instance) {
58 associated_instance_->AddPerInstanceObject(kPPPFindInterface, this); 55 Module::Get()->AddPluginInterface(kPPPFindInterface, &ppp_find);
56 Instance::AddPerInstanceObject(instance, kPPPFindInterface, this);
59 } 57 }
60 58
61 Find_Dev::~Find_Dev() { 59 Find_Dev::~Find_Dev() {
62 associated_instance_->RemovePerInstanceObject(kPPPFindInterface, this); 60 Instance::RemovePerInstanceObject(associated_instance_,
61 kPPPFindInterface, this);
63 } 62 }
64 63
65 void Find_Dev::NumberOfFindResultsChanged(int32_t total, bool final_result) { 64 void Find_Dev::NumberOfFindResultsChanged(int32_t total, bool final_result) {
66 if (has_interface<PPB_Find_Dev>()) { 65 if (has_interface<PPB_Find_Dev>()) {
67 get_interface<PPB_Find_Dev>()->NumberOfFindResultsChanged( 66 get_interface<PPB_Find_Dev>()->NumberOfFindResultsChanged(
68 associated_instance_->pp_instance(), total, PP_FromBool(final_result)); 67 associated_instance_.pp_instance(), total, PP_FromBool(final_result));
69 } 68 }
70 } 69 }
71 70
72 void Find_Dev::SelectedFindResultChanged(int32_t index) { 71 void Find_Dev::SelectedFindResultChanged(int32_t index) {
73 if (has_interface<PPB_Find_Dev>()) { 72 if (has_interface<PPB_Find_Dev>()) {
74 get_interface<PPB_Find_Dev>()->SelectedFindResultChanged( 73 get_interface<PPB_Find_Dev>()->SelectedFindResultChanged(
75 associated_instance_->pp_instance(), index); 74 associated_instance_.pp_instance(), index);
76 } 75 }
77 } 76 }
78 77
79 } // namespace pp 78 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/dev/find_dev.h ('k') | ppapi/cpp/dev/font_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698