| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 base64 | 5 import base64 |
| 6 import json | 6 import json |
| 7 import uuid | 7 import uuid |
| 8 | 8 |
| 9 class ClovisTask(object): | 9 class ClovisTask(object): |
| 10 """Generic task, generated by the AppEngine frontend and consumed by the | 10 """Generic task, generated by the AppEngine frontend and consumed by the |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 """Loads a ClovisTask from a JSON string. | 34 """Loads a ClovisTask from a JSON string. |
| 35 | 35 |
| 36 Returns: | 36 Returns: |
| 37 ClovisTask: The task, or None if the string is invalid. | 37 ClovisTask: The task, or None if the string is invalid. |
| 38 """ | 38 """ |
| 39 try: | 39 try: |
| 40 data = json.loads(json_dict) | 40 data = json.loads(json_dict) |
| 41 action = data['action'] | 41 action = data['action'] |
| 42 action_params = data['action_params'] | 42 action_params = data['action_params'] |
| 43 # Vaidate the format. | 43 # Vaidate the format. |
| 44 if action == 'trace': | 44 if action == 'trace' or action == 'report': |
| 45 urls = action_params['urls'] | 45 urls = action_params['urls'] |
| 46 if (type(urls) is not list) or (len(urls) == 0): | 46 if (type(urls) is not list) or (len(urls) == 0): |
| 47 return None | 47 return None |
| 48 else: | 48 else: |
| 49 # When more actions are supported, check that they are valid here. | 49 # When more actions are supported, check that they are valid here. |
| 50 return None | 50 return None |
| 51 return cls(action, action_params, data.get('backend_params')) | 51 return cls(action, action_params, data.get('backend_params')) |
| 52 except Exception: | 52 except Exception: |
| 53 return None | 53 return None |
| 54 | 54 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 65 | 65 |
| 66 def Action(self): | 66 def Action(self): |
| 67 return self._action | 67 return self._action |
| 68 | 68 |
| 69 def ActionParams(self): | 69 def ActionParams(self): |
| 70 return self._action_params | 70 return self._action_params |
| 71 | 71 |
| 72 def BackendParams(self): | 72 def BackendParams(self): |
| 73 return self._backend_params | 73 return self._backend_params |
| 74 | 74 |
| OLD | NEW |