2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
9 from trace_viewer import trace_viewer_project
12 def do_GET_json_examples(request):
13 test_data_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'test_data'))
15 for dirpath, dirnames, filenames in os.walk(test_data_path):
20 files_as_json = json.dumps(data_files)
22 request.send_response(200)
23 request.send_header('Content-Type', 'application/json')
24 request.send_header('Content-Length', len(files_as_json))
26 request.wfile.write(files_as_json)
28 def do_GET_json_examples_skp(request):
29 skp_data_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'skp_data'))
31 for dirpath, dirnames, filenames in os.walk(skp_data_path):
36 files_as_json = json.dumps(data_files)
38 request.send_response(200)
39 request.send_header('Content-Type', 'application/json')
40 request.send_header('Content-Length', len(files_as_json))
42 request.wfile.write(files_as_json)
45 project = trace_viewer_project.TraceViewerProject()
47 server = tvcm.DevServer(port=port, project=project)
48 server.AddPathHandler('/json/examples', do_GET_json_examples)
49 server.AddPathHandler('/json/examples/skp', do_GET_json_examples_skp)
51 server.AddSourcePathMapping(project.trace_viewer_path)
52 server.AddTestLink('/examples/skia_debugger.html', 'Skia Debugger')
53 server.AddTestLink('/examples/trace_viewer.html', 'Trace File Viewer')
54 server.serve_forever()
56 if __name__ == '__main__':
57 sys.exit(Main(port=8003, args=sys.argv[1:]))