Index: chrome/renderer/extensions/extension_request_sender.h |
diff --git a/chrome/renderer/extensions/extension_request_sender.h b/chrome/renderer/extensions/extension_request_sender.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d6d2c744b35d49b0ee5eebf0d5e61ca5fd94327e |
--- /dev/null |
+++ b/chrome/renderer/extensions/extension_request_sender.h |
@@ -0,0 +1,63 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_REQUEST_SENDER_H_ |
+#define CHROME_RENDERER_EXTENSIONS_EXTENSION_REQUEST_SENDER_H_ |
+#pragma once |
+ |
+#include <string> |
+#include <map> |
+ |
+#include "base/memory/linked_ptr.h" |
+#include "v8/include/v8.h" |
+ |
+class ChromeV8ContextSet; |
+class ExtensionDispatcher; |
+ |
+namespace base { |
+class ListValue; |
+} |
+ |
+struct PendingRequest; |
+ |
+// Calls a named extension API function in the extension host and routes the |
+// response back to the caller. |
not at google - send to devlin
2012/03/30 03:14:31
This reads more like the documentation that would
koz (OOO until 15th September)
2012/04/03 00:15:17
Done.
|
+class ExtensionRequestSender { |
+ public: |
+ explicit ExtensionRequestSender(ExtensionDispatcher* extension_dispatcher, |
+ ChromeV8ContextSet* context_set); |
+ ~ExtensionRequestSender(); |
+ |
+ // 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. |
+ void StartRequest(const std::string& name, |
not at google - send to devlin
2012/03/30 03:14:31
Looking at the implementation of this method it se
koz (OOO until 15th September)
2012/04/03 00:15:17
Perhaps the caller doesn't care? Maybe the silent
|
+ int request_id, |
+ bool has_callback, |
+ bool for_io_thread, |
+ base::ListValue* value_args); |
+ |
+ // Handles responses from the extension host to calls made by StartRequest(). |
+ void HandleResponse(int request_id, |
not at google - send to devlin
2012/03/30 03:14:31
"OnResponse" feels like a better name, it implies
koz (OOO until 15th September)
2012/04/03 00:15:17
Yeah, it doesn't seem worth the change. HandleResp
|
+ bool success, |
+ const std::string& response, |
+ const std::string& error); |
+ |
+ |
+ private: |
+ typedef std::map<int, linked_ptr<PendingRequest> > PendingRequestMap; |
+ |
+ void InsertRequest(int request_id, PendingRequest* pending_request); |
+ PendingRequest* GetPendingRequest(int request_id); |
+ void RemoveRequest(int request_id); |
+ |
+ ExtensionDispatcher* extension_dispatcher_; |
+ PendingRequestMap pending_requests_; |
+ ChromeV8ContextSet* context_set_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ExtensionRequestSender); |
+}; |
+ |
+#endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_REQUEST_SENDER_H_ |