Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tracinghandler.h
Go to the documentation of this file.
1 
18 #ifndef ION_REMOTE_TRACINGHANDLER_H_
19 #define ION_REMOTE_TRACINGHANDLER_H_
20 
21 #include <functional>
22 #include <sstream>
23 #include <string>
24 
25 #include "base/integral_types.h"
26 #include "ion/gfx/renderer.h"
27 #include "ion/gfxutils/frame.h"
28 #include "ion/port/semaphore.h"
29 #include "ion/remote/httpserver.h"
30 
31 namespace ion {
32 namespace remote {
33 
44  public:
49  const gfx::RendererPtr& renderer);
50 
51  ~TracingHandler() override;
52 
53  const std::string HandleRequest(const std::string& path,
54  const HttpServer::QueryMap& args,
55  std::string* content_type) override;
56 
57  private:
59  enum State {
60  kInactive, // Not actively tracing.
61  kWaitingForBeginFrame, // Waiting for BeginFrame() to be called.
62  kWaitingForEndFrame, // Waiting for EndFrame() to be called.
63  };
64 
66  void TraceNextFrame(bool block_until_frame_rendered);
67 
69  void BeginFrame(const gfxutils::Frame& frame);
70  void EndFrame(const gfxutils::Frame& frame);
71 
74  std::ostream* GetTracingStream() { return &tracing_stream_; }
75 
77  gfxutils::FramePtr frame_;
81  std::ostream* prev_stream_;
83  std::ostringstream tracing_stream_;
85  std::string html_string_;
87  port::Semaphore semaphore_;
89  State state_;
91  uint64 frame_counter_;
94  std::string resources_to_delete_;
95 
97  friend class TracingHandlerTest;
98 };
99 
100 } // namespace remote
101 } // namespace ion
102 
103 #endif // ION_REMOTE_TRACINGHANDLER_H_
A Semaphore enables threads and process synchronization.
Definition: semaphore.h:40
Frame manages an application-defined frame of execution.
Definition: frame.h:33
const RendererPtr & renderer_
Renderer used to render images.
std::map< std::string, std::string > QueryMap
Definition: httpserver.h:35
RequestHandlers handle requests for a file or path.
Definition: httpserver.h:68
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
Definition: sharedptr.h:60
TracingHandler serves files related to OpenGL tracing.