Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_context_observer.h
blob049cbfa1918e0d8d1a0e9befce881d8cec0a22e9
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.
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_OBSERVER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_OBSERVER_H_
8 #include "base/strings/string16.h"
9 #include "base/time/time.h"
10 #include "content/browser/service_worker/service_worker_version.h"
11 #include "url/gurl.h"
13 namespace content {
15 class ServiceWorkerContextObserver {
16 public:
17 struct ErrorInfo {
18 ErrorInfo(const base::string16& message,
19 int line,
20 int column,
21 const GURL& url)
22 : error_message(message),
23 line_number(line),
24 column_number(column),
25 source_url(url) {}
26 const base::string16 error_message;
27 const int line_number;
28 const int column_number;
29 const GURL source_url;
31 struct ConsoleMessage {
32 ConsoleMessage(int source_identifier,
33 int message_level,
34 const base::string16& message,
35 int line_number,
36 const GURL& source_url)
37 : source_identifier(source_identifier),
38 message_level(message_level),
39 message(message),
40 line_number(line_number),
41 source_url(source_url) {}
42 const int source_identifier;
43 const int message_level;
44 const base::string16 message;
45 const int line_number;
46 const GURL source_url;
48 virtual void OnNewLiveRegistration(int64 registration_id,
49 const GURL& pattern) {}
50 virtual void OnNewLiveVersion(int64 version_id,
51 int64 registration_id,
52 const GURL& script_url) {}
53 virtual void OnRunningStateChanged(
54 int64 version_id,
55 ServiceWorkerVersion::RunningStatus running_status) {}
56 virtual void OnVersionStateChanged(int64 version_id,
57 ServiceWorkerVersion::Status status) {}
58 virtual void OnMainScriptHttpResponseInfoSet(
59 int64 version_id,
60 base::Time script_response_time,
61 base::Time script_last_modified) {}
62 virtual void OnErrorReported(int64 version_id,
63 int process_id,
64 int thread_id,
65 const ErrorInfo& info) {}
66 virtual void OnReportConsoleMessage(int64 version_id,
67 int process_id,
68 int thread_id,
69 const ConsoleMessage& message) {}
70 virtual void OnRegistrationStored(int64 registration_id,
71 const GURL& pattern) {}
72 virtual void OnRegistrationDeleted(int64 registration_id,
73 const GURL& pattern) {}
75 // Notified when the storage corruption recovery is completed and all stored
76 // data is wiped out.
77 virtual void OnStorageWiped() {}
79 protected:
80 virtual ~ServiceWorkerContextObserver() {}
83 } // namespace content
85 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_OBSERVER_H_