Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
calltracehandler.cc
Go to the documentation of this file.
1 
18 #if !ION_PRODUCTION
19 
21 
22 #include "ion/base/invalid.h"
23 #include "ion/base/serialize.h"
24 #include "ion/base/stringutils.h"
27 #include "ion/profile/profiling.h"
28 
29 ION_REGISTER_ASSETS(IonRemoteCallTraceRoot);
30 
31 namespace ion {
32 namespace remote {
33 
35  : ion::remote::HttpServer::RequestHandler("/ion/calltrace") {
36  IonRemoteCallTraceRoot::RegisterAssetsOnce();
37 }
38 
40 
42  const std::string& path_in, const ion::remote::HttpServer::QueryMap& args,
43  std::string* content_type) {
44  const std::string path = path_in.empty() ? "index.html" : path_in;
45 
46  if (path == "call.wtf-trace") {
47  *content_type = "application/x-extension-wtf-trace";
49  return tm->SnapshotCallTraces();
50  } else {
51  const std::string& data =
52  base::ZipAssetManager::GetFileData("ion/calltrace/" + path);
53  if (!base::IsInvalidReference(data)) {
55  if (base::EndsWith(path, "html"))
56  *content_type = "text/html";
57  return data;
58  }
59  }
60  return std::string();
61 }
62 
63 } // namespace remote
64 } // namespace ion
65 
66 #endif
bool IsInvalidReference(const T &value)
IsInvalidReference() returns true if a passed const reference of type T has an address of InvalidRefe...
Definition: invalid.h:41
ION_REGISTER_ASSETS(IonRemoteCallTraceRoot)
Copyright 2016 Google Inc.
CallTraceManager * GetCallTraceManager()
Get the global, static instance of CallTraceManager.
Definition: profiling.cc:25
static const std::string & GetFileData(const std::string &filename)
Returns the data of the passed filename if the manager contains it.
const std::string HandleRequest(const std::string &path_in, const ion::remote::HttpServer::QueryMap &args, std::string *content_type) override
The HandleRequest() function is passed the path (relative to its base path) of the file or directory ...
std::string SnapshotCallTraces() const
Returns a snapshot of traces to a string in binary .wtf-trace format.
bool EndsWith(const std::string &target, const std::string &end)
Returns whether target ends with end.
Definition: stringutils.h:81
Manages call trace recording for visualization in Web Tracing Framework (WTF) format.
std::map< std::string, std::string > QueryMap
Definition: httpserver.h:35