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

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

Issue 9903010: Extract ExtensionRequestSender from SchemaGeneratedBindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
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..250905b64360ac86e9fc6763d500322cd7b2217d
--- /dev/null
+++ b/chrome/renderer/extensions/extension_request_sender.h
@@ -0,0 +1,57 @@
+// 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 method in the browser.
benwells 2012/03/29 23:06:36 ... and routes the responses back to the caller.
koz (OOO until 15th September) 2012/03/29 23:55:46 Done.
+class ExtensionRequestSender {
+ public:
+ explicit ExtensionRequestSender(ExtensionDispatcher* extension_dispatcher,
+ ChromeV8ContextSet* context_set);
+ ~ExtensionRequestSender();
+
+ void HandleResponse(int request_id,
benwells 2012/03/29 23:06:36 Would be nice to document how these two methods ar
koz (OOO until 15th September) 2012/03/29 23:55:46 Done.
+ bool success,
+ const std::string& response,
+ const std::string& error);
+
+ void StartRequest(const std::string& name,
+ int request_id,
benwells 2012/03/29 23:06:36 Could you also move the GetNextRequestId stuff in
koz (OOO until 15th September) 2012/03/29 23:55:46 As discussed, I'll do this in a follow-up CL. I've
+ bool has_callback,
+ bool for_io_thread,
+ base::ListValue* value_args);
+
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698