Index: components/guest_view/renderer/guest_view_request.h |
diff --git a/components/guest_view/renderer/guest_view_request.h b/components/guest_view/renderer/guest_view_request.h |
index 2c50a44affbb8bbe0c6bc13c542e822efb6c4d5d..079408e07789facef45073bc32ff38ab85cc11c2 100644 |
--- a/components/guest_view/renderer/guest_view_request.h |
+++ b/components/guest_view/renderer/guest_view_request.h |
@@ -14,17 +14,15 @@ namespace guest_view { |
class GuestViewContainer; |
// A GuestViewRequest is the base class for an asynchronous operation performed |
-// on a GuestView or GuestViewContainer from JavaScript. This operation may be |
-// queued until the container is ready to be operated upon (it has geometry). |
+// on a GuestView or GuestViewContainer. This operation may be queued until the |
+// container is ready to be operated upon (it has geometry). |
// A GuestViewRequest may or may not have a callback back into JavaScript. |
// Typically, performing a request involves sending an IPC to the browser |
// process in PerformRequest. Handling a response involves receiving a related |
// IPC from the browser process in HandleResponse. |
class GuestViewRequest { |
public: |
- GuestViewRequest(GuestViewContainer* container, |
- v8::Local<v8::Function> callback, |
- v8::Isolate* isolate); |
+ GuestViewRequest(GuestViewContainer* container); |
virtual ~GuestViewRequest(); |
// Performs the associated request. |
@@ -34,30 +32,44 @@ class GuestViewRequest { |
// request initiated by PerformRequest. |
virtual void HandleResponse(const IPC::Message& message) = 0; |
- // Called to call the callback associated with this request if one is |
- // available. |
- // Note: the callback may be called even if a response has not been heard from |
- // the browser process if the GuestViewContainer is being torn down. |
+ // Called during tear down to perform the default response action. |
+ virtual void HandleDefaultResponse() = 0; |
+ |
+ GuestViewContainer* container() const { return container_; } |
+ |
+ private: |
+ GuestViewContainer* const container_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(GuestViewRequest); |
+}; |
+ |
+// A GuestViewJavaScriptRequest is an asynchronous GuestView operation initiated |
+// from JavaScript |
+class GuestViewJavaScriptRequest : public GuestViewRequest { |
+ public: |
+ GuestViewJavaScriptRequest(GuestViewContainer* container, |
+ v8::Local<v8::Function> callback, |
+ v8::Isolate* isolate); |
+ ~GuestViewJavaScriptRequest() override; |
+ |
void ExecuteCallbackIfAvailable(int argc, |
scoped_ptr<v8::Local<v8::Value>[]> argv); |
- GuestViewContainer* container() const { return container_; } |
+ // GuestViewRequest implementation: |
+ void HandleDefaultResponse() override; |
v8::Isolate* isolate() const { return isolate_; } |
private: |
- GuestViewContainer* const container_; |
v8::Global<v8::Function> callback_; |
v8::Isolate* const isolate_; |
- |
- DISALLOW_COPY_AND_ASSIGN(GuestViewRequest); |
}; |
// This class represents an AttachGuest request from Javascript. It includes |
// the input parameters and the callback function. The Attach operation may |
// not execute immediately, if the container is not ready or if there are |
// other GuestViewRequests in flight. |
-class GuestViewAttachRequest : public GuestViewRequest { |
+class GuestViewAttachRequest : public GuestViewJavaScriptRequest { |
public: |
GuestViewAttachRequest(GuestViewContainer* container, |
int guest_instance_id, |
@@ -79,7 +91,7 @@ class GuestViewAttachRequest : public GuestViewRequest { |
// This class represents a DetachGuest request from Javascript. The Detach |
// operation may not execute immediately, if the container is not ready or if |
// there are other GuestViewRequests in flight. |
-class GuestViewDetachRequest : public GuestViewRequest { |
+class GuestViewDetachRequest : public GuestViewJavaScriptRequest { |
public: |
GuestViewDetachRequest(GuestViewContainer* container, |
v8::Local<v8::Function> callback, |