Flutter Engine
vmservice_object.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 #include "vmservice_object.h"
6 
7 #include <dirent.h>
8 #include <fuchsia/io/cpp/fidl.h>
9 #include <lib/syslog/global.h>
10 #include <zircon/status.h>
11 
12 #include <cerrno>
13 #include <string>
14 
15 #include "logging.h"
16 
17 namespace {
18 
19 bool ReadDirContents(const std::string& path, std::vector<std::string>* out) {
20  out->clear();
21  DIR* dir = opendir(path.c_str());
22  if (!dir) {
23  return false;
24  }
25  struct dirent* de;
26  errno = 0;
27  while ((de = readdir(dir)) != nullptr) {
28  out->push_back(de->d_name);
29  }
30  closedir(dir);
31  return !errno;
32 }
33 
34 } // namespace
35 
36 namespace dart_utils {
37 
38 void VMServiceObject::GetContents(LazyEntryVector* out_vector) const {
39  // List /tmp/dart.services if it exists, and push its contents as
40  // as the conrtents of this directory.
41  std::vector<std::string> files;
42  if (!ReadDirContents(kPortDir, &files)) {
43  FX_LOGF(ERROR, LOG_TAG,
44  "Failed to read Dart VM service port directory '%s': %s", kPortDir,
45  strerror(errno));
46  return;
47  }
48  for (const auto& file : files) {
49  if ((file == ".") || (file == "..")) {
50  continue;
51  }
52  out_vector->push_back({std::stoul(file) + GetStartingId(), file,
53  fuchsia::io::MODE_TYPE_FILE});
54  }
55 }
56 
57 zx_status_t VMServiceObject::GetFile(Node** out_node,
58  uint64_t id,
59  std::string name) const {
60  return ZX_ERR_NOT_FOUND;
61 }
62 
63 } // namespace dart_utils
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data observatory The hostname IP address on which the Dart Observatory should be served If not defaults to or::depending on whether ipv6 is specified disable Disable the Dart Observatory The observatory is never available in release mode Bind to the IPv6 localhost address for the Dart Observatory Ignored if observatory host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition: switches.h:117
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
zx_status_t GetFile(Node **out_node, uint64_t id, std::string name) const override
static constexpr const char * kPortDir
#define LOG_TAG
Definition: logging.h:11
void GetContents(LazyEntryVector *out_vector) const override
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57