15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/private/flash_device_id.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_errors.h"
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_flash_device_id.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/module_impl.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace pp {
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)template <> const char* interface_name<PPB_Flash_DeviceID_1_0>() {
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return PPB_FLASH_DEVICEID_INTERFACE_1_0;
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace flash {
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)DeviceID::DeviceID() {
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)DeviceID::DeviceID(const InstanceHandle& instance) : Resource() {
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (has_interface<PPB_Flash_DeviceID_1_0>()) {
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PassRefFromConstructor(get_interface<PPB_Flash_DeviceID_1_0>()->Create(
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        instance.pp_instance()));
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int32_t DeviceID::GetDeviceID(
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const CompletionCallbackWithOutput<Var>& callback) {
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (has_interface<PPB_Flash_DeviceID_1_0>()) {
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return get_interface<PPB_Flash_DeviceID_1_0>()->GetDeviceID(
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        pp_resource(),
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        callback.output(),
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        callback.pp_completion_callback());
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return callback.MayForce(PP_ERROR_NOINTERFACE);
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace flash
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace pp
46