OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Created on the main thread, and may be passed to another script context | 46 // Created on the main thread, and may be passed to another script context |
47 // thread (e.g. worker thread) later. All methods of this class must be called | 47 // thread (e.g. worker thread) later. All methods of this class must be called |
48 // on the single script context thread. | 48 // on the single script context thread. |
49 class WebServiceWorkerProvider { | 49 class WebServiceWorkerProvider { |
50 public: | 50 public: |
51 // Called when a client wants to start listening to the service worker | 51 // Called when a client wants to start listening to the service worker |
52 // events. Must be cleared before the client becomes invalid. | 52 // events. Must be cleared before the client becomes invalid. |
53 virtual void setClient(WebServiceWorkerProviderClient*) { } | 53 virtual void setClient(WebServiceWorkerProviderClient*) { } |
54 | 54 |
55 class WebServiceWorkerRegistrationCallbacks : public WebCallbacks<WebPassOwn
Ptr<WebServiceWorkerRegistration>, const WebServiceWorkerError&> { | 55 using WebServiceWorkerRegistrationCallbacks = WebCallbacks<WebPassOwnPtr<Web
ServiceWorkerRegistration>, const WebServiceWorkerError&>; |
56 public: | 56 using WebServiceWorkerGetRegistrationCallbacks = WebCallbacks<WebPassOwnPtr<
WebServiceWorkerRegistration>, const WebServiceWorkerError&>; |
57 void onSuccess(WebServiceWorkerRegistration* r) { onSuccess(adoptWebPtr(
r)); } | 57 // Each element's ownership is transferred. |
58 void onError(WebServiceWorkerError* e) | 58 // TODO(yhirano): Consider using vector<scoped_ptr<>>. |
59 { | 59 using WebServiceWorkerGetRegistrationsCallbacks = WebCallbacks<WebPassOwnPtr
<WebVector<WebServiceWorkerRegistration*>>, const WebServiceWorkerError&>; |
60 onError(*e); | 60 using WebServiceWorkerGetRegistrationForReadyCallbacks = WebCallbacks<WebPas
sOwnPtr<WebServiceWorkerRegistration>, void>; |
61 delete e; | |
62 } | |
63 virtual void onSuccess(WebPassOwnPtr<WebServiceWorkerRegistration>) = 0; | |
64 virtual void onError(const WebServiceWorkerError&) = 0; | |
65 }; | |
66 using WebServiceWorkerGetRegistrationCallbacks = WebServiceWorkerRegistratio
nCallbacks; | |
67 class WebServiceWorkerGetRegistrationsCallbacks : public WebCallbacks<WebPas
sOwnPtr<WebVector<WebServiceWorkerRegistration*>>, const WebServiceWorkerError&>
{ | |
68 public: | |
69 void onSuccess(WebVector<WebServiceWorkerRegistration*>* r) { onSuccess(
adoptWebPtr(r)); } | |
70 void onError(WebServiceWorkerError* e) | |
71 { | |
72 onError(*e); | |
73 delete e; | |
74 } | |
75 virtual void onSuccess(WebPassOwnPtr<WebVector<WebServiceWorkerRegistrat
ion*>>) = 0; | |
76 virtual void onError(const WebServiceWorkerError&) = 0; | |
77 }; | |
78 class WebServiceWorkerGetRegistrationForReadyCallbacks : public WebCallbacks
<WebPassOwnPtr<WebServiceWorkerRegistration>, void> { | |
79 public: | |
80 void onSuccess(WebServiceWorkerRegistration* r) { onSuccess(adoptWebPtr(
r)); } | |
81 virtual void onSuccess(WebPassOwnPtr<WebServiceWorkerRegistration>) = 0; | |
82 }; | |
83 | 61 |
84 virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scri
ptUrl, WebServiceWorkerRegistrationCallbacks*) { } | 62 virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scri
ptUrl, WebServiceWorkerRegistrationCallbacks*) { } |
85 virtual void getRegistration(const WebURL& documentURL, WebServiceWorkerGetR
egistrationCallbacks*) { } | 63 virtual void getRegistration(const WebURL& documentURL, WebServiceWorkerGetR
egistrationCallbacks*) { } |
86 virtual void getRegistrations(WebServiceWorkerGetRegistrationsCallbacks*) {
} | 64 virtual void getRegistrations(WebServiceWorkerGetRegistrationsCallbacks*) {
} |
87 virtual void getRegistrationForReady(WebServiceWorkerGetRegistrationForReady
Callbacks*) { } | 65 virtual void getRegistrationForReady(WebServiceWorkerGetRegistrationForReady
Callbacks*) { } |
88 virtual bool validateScopeAndScriptURL(const WebURL& scope, const WebURL& sc
riptURL, WebString* errorMessage) { return false; } | 66 virtual bool validateScopeAndScriptURL(const WebURL& scope, const WebURL& sc
riptURL, WebString* errorMessage) { return false; } |
89 | 67 |
90 virtual ~WebServiceWorkerProvider() { } | 68 virtual ~WebServiceWorkerProvider() { } |
91 }; | 69 }; |
92 | 70 |
93 } // namespace blink | 71 } // namespace blink |
94 | 72 |
95 #endif | 73 #endif |
OLD | NEW |