Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6464)

Unified Diff: chrome/renderer/extensions/request_sender.h

Issue 12567028: Apps V2 in Pepper: Host side implementation of ExntensionsCommon - Part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/extensions/dispatcher.cc ('k') | chrome/renderer/extensions/request_sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/request_sender.h
diff --git a/chrome/renderer/extensions/request_sender.h b/chrome/renderer/extensions/request_sender.h
index b1463fd36b9250f0744d305931d2e91690df46d7..618a9678967adfd3660460912c142c28a09f4d5d 100644
--- a/chrome/renderer/extensions/request_sender.h
+++ b/chrome/renderer/extensions/request_sender.h
@@ -25,16 +25,37 @@ struct PendingRequest;
// 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;
asargent_no_longer_on_chrome 2013/03/28 20:33:26 Eventually it might be interesting to abstract thi
yzshen1 2013/03/28 22:25:22 I will bear that in mind. I think I will touch thi
+ 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 @@ class RequestSender {
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;
« no previous file with comments | « chrome/renderer/extensions/dispatcher.cc ('k') | chrome/renderer/extensions/request_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698