1// Copyright (c) 2013 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.
4
5#ifndef PPAPI_PROXY_TRUETYPE_FONT_SINGLETON_RESOURCE_H_
6#define PPAPI_PROXY_TRUETYPE_FONT_SINGLETON_RESOURCE_H_
7
8#include <string>
9#include <vector>
10
11#include "ppapi/proxy/connection.h"
12#include "ppapi/proxy/plugin_resource.h"
13#include "ppapi/thunk/ppb_truetype_font_singleton_api.h"
14
15namespace ppapi {
16
17class TrackedCallback;
18
19namespace proxy {
20
21struct SerializedTrueTypeFontDesc;
22
23// This handles the singleton calls (that don't take a PP_Resource parameter)
24// on the TrueType font interface.
25class TrueTypeFontSingletonResource
26    : public PluginResource,
27      public thunk::PPB_TrueTypeFont_Singleton_API {
28 public:
29  TrueTypeFontSingletonResource(Connection connection, PP_Instance instance);
30  virtual ~TrueTypeFontSingletonResource();
31
32  // Resource override.
33  virtual thunk::PPB_TrueTypeFont_Singleton_API*
34      AsPPB_TrueTypeFont_Singleton_API() OVERRIDE;
35
36  // thunk::PPB_TrueTypeFont_Singleton_API implementation.
37  virtual int32_t GetFontFamilies(
38      PP_Instance instance,
39      const PP_ArrayOutput& output,
40      const scoped_refptr<TrackedCallback>& callback) OVERRIDE;
41  virtual int32_t GetFontsInFamily(
42      PP_Instance instance,
43      PP_Var family,
44      const PP_ArrayOutput& output,
45      const scoped_refptr<TrackedCallback>& callback) OVERRIDE;
46
47 private:
48  void OnPluginMsgGetFontFamiliesComplete(
49      scoped_refptr<TrackedCallback> callback,
50      PP_ArrayOutput array_output,
51      const ResourceMessageReplyParams& params,
52      const std::vector<std::string>& data);
53  void OnPluginMsgGetFontsInFamilyComplete(
54      scoped_refptr<TrackedCallback> callback,
55      PP_ArrayOutput array_output,
56      const ResourceMessageReplyParams& params,
57      const std::vector<SerializedTrueTypeFontDesc>& fonts);
58
59  DISALLOW_COPY_AND_ASSIGN(TrueTypeFontSingletonResource);
60};
61
62}  // namespace proxy
63}  // namespace ppapi
64
65#endif  // PPAPI_PROXY_TRUETYPE_FONT_SINGLETON_RESOURCE_H_
66