1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_OBSERVER_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_OBSERVER_H_ 7 8 #include "base/strings/string16.h" 9 #include "url/gurl.h" 10 11 namespace content { 12 13 class ServiceWorkerContextObserver { 14 public: 15 struct ErrorInfo { 16 ErrorInfo(const base::string16& message, 17 int line, 18 int column, 19 const GURL& url) 20 : error_message(message), 21 line_number(line), 22 column_number(column), 23 source_url(url) {} 24 const base::string16 error_message; 25 const int line_number; 26 const int column_number; 27 const GURL source_url; 28 }; 29 struct ConsoleMessage { 30 ConsoleMessage(int source_identifier, 31 int message_level, 32 const base::string16& message, 33 int line_number, 34 const GURL& source_url) 35 : source_identifier(source_identifier), 36 message_level(message_level), 37 message(message), 38 line_number(line_number), 39 source_url(source_url) {} 40 const int source_identifier; 41 const int message_level; 42 const base::string16 message; 43 const int line_number; 44 const GURL source_url; 45 }; 46 virtual void OnWorkerStarted(int64 version_id, 47 int process_id, 48 int thread_id) {} 49 virtual void OnWorkerStopped(int64 version_id, 50 int process_id, 51 int thread_id) {} 52 virtual void OnVersionStateChanged(int64 version_id) {} 53 virtual void OnErrorReported(int64 version_id, 54 int process_id, 55 int thread_id, 56 const ErrorInfo& info) {} 57 virtual void OnReportConsoleMessage(int64 version_id, 58 int process_id, 59 int thread_id, 60 const ConsoleMessage& message) {} 61 virtual void OnRegistrationStored(const GURL& pattern) {} 62 virtual void OnRegistrationDeleted(const GURL& pattern) {} 63 64 protected: 65 virtual ~ServiceWorkerContextObserver() {} 66 }; 67 68 } // namespace content 69 70 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_OBSERVER_H_ 71