Move prefs::kLastPolicyStatisticsUpdate to the policy component.
[chromium-blink-merge.git] / ppapi / shared_impl / ppp_instance_combined.cc
blob5baaf12c12b11b92c901e19ed405bdfe7e3b7581
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/shared_impl/ppp_instance_combined.h"
6 #include "ppapi/shared_impl/proxy_lock.h"
8 namespace ppapi {
10 // static
11 PPP_Instance_Combined* PPP_Instance_Combined::Create(
12 base::Callback<const void*(const char*)> get_interface_func) {
13 // Try 1.1.
14 const void* ppp_instance = get_interface_func.Run(PPP_INSTANCE_INTERFACE_1_1);
15 if (ppp_instance) {
16 const PPP_Instance_1_1* ppp_instance_1_1 =
17 static_cast<const PPP_Instance_1_1*>(ppp_instance);
18 return new PPP_Instance_Combined(*ppp_instance_1_1);
20 // Failing that, try 1.0.
21 ppp_instance = get_interface_func.Run(PPP_INSTANCE_INTERFACE_1_0);
22 if (ppp_instance) {
23 const PPP_Instance_1_0* ppp_instance_1_0 =
24 static_cast<const PPP_Instance_1_0*>(ppp_instance);
25 return new PPP_Instance_Combined(*ppp_instance_1_0);
27 // No supported PPP_Instance version found.
28 return NULL;
31 PPP_Instance_Combined::PPP_Instance_Combined(
32 const PPP_Instance_1_0& instance_if)
33 : did_change_view_1_0_(instance_if.DidChangeView) {
34 instance_1_1_.DidCreate = instance_if.DidCreate;
35 instance_1_1_.DidDestroy = instance_if.DidDestroy;
36 instance_1_1_.DidChangeView = NULL;
37 instance_1_1_.DidChangeFocus = instance_if.DidChangeFocus;
38 instance_1_1_.HandleDocumentLoad = instance_if.HandleDocumentLoad;
41 PPP_Instance_Combined::PPP_Instance_Combined(
42 const PPP_Instance_1_1& instance_if)
43 : instance_1_1_(instance_if),
44 did_change_view_1_0_(NULL) {
47 PP_Bool PPP_Instance_Combined::DidCreate(PP_Instance instance,
48 uint32_t argc,
49 const char* argn[],
50 const char* argv[]) {
51 return CallWhileUnlocked(instance_1_1_.DidCreate, instance, argc, argn, argv);
54 void PPP_Instance_Combined::DidDestroy(PP_Instance instance) {
55 return CallWhileUnlocked(instance_1_1_.DidDestroy, instance);
58 void PPP_Instance_Combined::DidChangeView(PP_Instance instance,
59 PP_Resource view_changed_resource,
60 const struct PP_Rect* position,
61 const struct PP_Rect* clip) {
62 if (instance_1_1_.DidChangeView) {
63 CallWhileUnlocked(instance_1_1_.DidChangeView,
64 instance,
65 view_changed_resource);
66 } else {
67 CallWhileUnlocked(did_change_view_1_0_, instance, position, clip);
71 void PPP_Instance_Combined::DidChangeFocus(PP_Instance instance,
72 PP_Bool has_focus) {
73 CallWhileUnlocked(instance_1_1_.DidChangeFocus, instance, has_focus);
76 PP_Bool PPP_Instance_Combined::HandleDocumentLoad(PP_Instance instance,
77 PP_Resource url_loader) {
78 return CallWhileUnlocked(instance_1_1_.HandleDocumentLoad,
79 instance,
80 url_loader);
83 } // namespace ppapi