Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1568)

Side by Side Diff: tools/deep_memory_profiler/visualizer/app.py

Issue 24534002: Add share button to generate public url for dmprof visualizer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review problems Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/deep_memory_profiler/visualizer/index.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import jinja2 5 import jinja2
6 import json
6 import os 7 import os
8 import re
7 import urllib 9 import urllib
8 import webapp2 10 import webapp2
9 11
10 from google.appengine.ext import blobstore 12 from google.appengine.ext import blobstore
11 from google.appengine.ext.webapp import blobstore_handlers 13 from google.appengine.ext.webapp import blobstore_handlers
12 14
13 import services 15 import services
14 16
15 17
16 JINJA_ENVIRONMENT = jinja2.Environment( 18 JINJA_ENVIRONMENT = jinja2.Environment(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 else: 63 else:
62 # Jump to new graph page using default template. 64 # Jump to new graph page using default template.
63 req_params = { 65 req_params = {
64 'run_id': run_id, 66 'run_id': run_id,
65 'tmpl_id': default_key.urlsafe() 67 'tmpl_id': default_key.urlsafe()
66 } 68 }
67 69
68 self.redirect('/?' + urllib.urlencode(req_params)) 70 self.redirect('/?' + urllib.urlencode(req_params))
69 71
70 72
73 class ShareHandler(webapp2.RequestHandler):
74 """Handle breakdown template sharing. Generate public url for transferred
75 template and return it back."""
76 def post(self):
77 run_id = self.request.POST['run_id']
78 content = json.loads(self.request.POST['content'])
79 tmpl_key = services.CreateTemplate(content)
80
81 req_params = {
82 'run_id': run_id,
83 'tmpl_id': tmpl_key.urlsafe()
84 }
85
86 # Take out host url from request by removing share suffix.
87 url = re.sub('share', '', self.request.url)
88 self.response.write(url + '?' + urllib.urlencode(req_params))
89
90
71 application = webapp2.WSGIApplication([ 91 application = webapp2.WSGIApplication([
72 ('/', MainPage), 92 ('/', MainPage),
73 ('/upload', UploadHandler) 93 ('/upload', UploadHandler),
94 ('/share', ShareHandler)
74 ], debug=True) 95 ], debug=True)
OLDNEW
« no previous file with comments | « no previous file | tools/deep_memory_profiler/visualizer/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698