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"
15 class ServiceWorkerContextObserver
{
18 ErrorInfo(const base::string16
& message
,
22 : error_message(message
),
24 column_number(column
),
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
,
34 const base::string16
& message
,
36 const GURL
& source_url
)
37 : source_identifier(source_identifier
),
38 message_level(message_level
),
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(
55 ServiceWorkerVersion::RunningStatus running_status
) {}
56 virtual void OnVersionStateChanged(int64 version_id
,
57 ServiceWorkerVersion::Status status
) {}
58 virtual void OnMainScriptHttpResponseInfoSet(
60 base::Time script_response_time
,
61 base::Time script_last_modified
) {}
62 virtual void OnErrorReported(int64 version_id
,
65 const ErrorInfo
& info
) {}
66 virtual void OnReportConsoleMessage(int64 version_id
,
69 const ConsoleMessage
& message
) {}
70 virtual void OnControlleeAdded(int64 version_id
,
71 const std::string
& uuid
,
74 ServiceWorkerProviderType type
) {}
75 virtual void OnControlleeRemoved(int64 version_id
, const std::string
& uuid
) {}
76 virtual void OnRegistrationStored(int64 registration_id
,
77 const GURL
& pattern
) {}
78 virtual void OnRegistrationDeleted(int64 registration_id
,
79 const GURL
& pattern
) {}
81 // Notified when the storage corruption recovery is completed and all stored
83 virtual void OnStorageWiped() {}
86 virtual ~ServiceWorkerContextObserver() {}
89 } // namespace content
91 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_OBSERVER_H_