platform_view_service_protocol.h 3.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SHELL_COMMON_VIEW_SERVICE_PROTOCOL_H_
#define SHELL_COMMON_VIEW_SERVICE_PROTOCOL_H_

#include <memory>

#include "flutter/shell/common/platform_view.h"
#include "lib/fxl/synchronization/waitable_event.h"
#include "third_party/dart/runtime/include/dart_tools_api.h"
#include "third_party/skia/include/core/SkBitmap.h"

namespace shell {

class PlatformViewServiceProtocol {
 public:
  static void RegisterHook(bool running_precompiled_code);

 private:
  static const char* kRunInViewExtensionName;
  // It should be invoked from the VM Service and and blocks it until previous
  // UI thread tasks are processed.
  static bool RunInView(const char* method,
                        const char** param_keys,
                        const char** param_values,
                        intptr_t num_params,
                        void* user_data,
                        const char** json_object);

  static const char* kListViewsExtensionName;
  static bool ListViews(const char* method,
                        const char** param_keys,
                        const char** param_values,
                        intptr_t num_params,
                        void* user_data,
                        const char** json_object);

  static const char* kScreenshotExtensionName;
  // It should be invoked from the VM Service and and blocks it until previous
  // GPU thread tasks are processed.
  static bool Screenshot(const char* method,
                         const char** param_keys,
                         const char** param_values,
                         intptr_t num_params,
                         void* user_data,
                         const char** json_object);
  static void ScreenshotGpuTask(SkBitmap* bitmap);

  static const char* kScreenshotSkpExtensionName;
  static bool ScreenshotSkp(const char* method,
                            const char** param_keys,
                            const char** param_values,
                            intptr_t num_params,
                            void* user_data,
                            const char** json_object);
  static sk_sp<SkPicture> ScreenshotSkpGpuTask();

  // This API should not be invoked by production code.
  // It can potentially starve the service isolate if the main isolate pauses
  // at a breakpoint or is in an infinite loop.
  //
  // It should be invoked from the VM Service and and blocks it until previous
  // GPU thread tasks are processed.
  static const char* kFlushUIThreadTasksExtensionName;
  static bool FlushUIThreadTasks(const char* method,
                                 const char** param_keys,
                                 const char** param_values,
                                 intptr_t num_params,
                                 void* user_data,
                                 const char** json_object);

  static const char* kSetAssetBundlePathExtensionName;
  static bool SetAssetBundlePath(const char* method,
                                 const char** param_keys,
                                 const char** param_values,
                                 intptr_t num_params,
                                 void* user_data,
                                 const char** json_object);
};

}  // namespace shell

#endif  // SHELL_COMMON_VIEW_SERVICE_PROTOCOL_H_