Apps V2 in Pepper: Host side implementation of ExntensionsCommon - Part 1.
This change handles the most common case: There is no need to call into JS custom bindings; requests are directly relayed to the browser process.
BUG=None
TEST=None
Review URL: https://chromiumcodereview.appspot.com/12567028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191355 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/renderer/extensions/request_sender.h b/chrome/renderer/extensions/request_sender.h
index b1463fd..618a9678 100644
--- a/chrome/renderer/extensions/request_sender.h
+++ b/chrome/renderer/extensions/request_sender.h
@@ -25,16 +25,37 @@
// extension host and routing the responses back to the caller.
class RequestSender {
public:
+ // Source represents a user of RequestSender. Every request is associated with
+ // a Source object, which will be notified when the corresponding response
+ // arrives. When a Source object is going away and there are pending requests,
+ // it should call InvalidateSource() to make sure no notifications are sent to
+ // it later.
+ class Source {
+ public:
+ virtual ~Source() {}
+
+ virtual ChromeV8Context* GetContext() = 0;
+ virtual void OnResponseReceived(const std::string& name,
+ int request_id,
+ bool success,
+ const base::ListValue& response,
+ const std::string& error) = 0;
+ };
+
explicit RequestSender(Dispatcher* dispatcher);
~RequestSender();
+ // In order to avoid collision, all |request_id|s passed into StartRequest()
+ // should be generated by this method.
+ int GetNextRequestId() const;
+
// Makes a call to the API function |name| that is to be handled by the
// extension host. The response to this request will be received in
// HandleResponse().
// TODO(koz): Remove |request_id| and generate that internally.
// There are multiple of these per render view though, so we'll
// need to vend the IDs centrally.
- void StartRequest(ChromeV8Context* target_context,
+ void StartRequest(Source* source,
const std::string& name,
int request_id,
bool has_callback,
@@ -47,9 +68,9 @@
const base::ListValue& response,
const std::string& error);
- // Notifies this that a context is no longer valid.
+ // Notifies this that a request source is no longer valid.
// TODO(kalman): Do this in a generic/safe way.
- void InvalidateContext(ChromeV8Context* context);
+ void InvalidateSource(Source* source);
private:
typedef std::map<int, linked_ptr<PendingRequest> > PendingRequestMap;