OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_REQUEST_SENDER_H_ | |
6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_REQUEST_SENDER_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 #include <map> | |
11 | |
12 #include "base/memory/linked_ptr.h" | |
13 #include "v8/include/v8.h" | |
14 | |
15 class ChromeV8ContextSet; | |
16 class ExtensionDispatcher; | |
17 | |
18 namespace base { | |
19 class ListValue; | |
20 } | |
21 | |
22 struct PendingRequest; | |
23 | |
24 // 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.
| |
25 class ExtensionRequestSender { | |
26 public: | |
27 explicit ExtensionRequestSender(ExtensionDispatcher* extension_dispatcher, | |
28 ChromeV8ContextSet* context_set); | |
29 ~ExtensionRequestSender(); | |
30 | |
31 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.
| |
32 bool success, | |
33 const std::string& response, | |
34 const std::string& error); | |
35 | |
36 void StartRequest(const std::string& name, | |
37 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
| |
38 bool has_callback, | |
39 bool for_io_thread, | |
40 base::ListValue* value_args); | |
41 | |
42 | |
43 private: | |
44 typedef std::map<int, linked_ptr<PendingRequest> > PendingRequestMap; | |
45 | |
46 void InsertRequest(int request_id, PendingRequest* pending_request); | |
47 PendingRequest* GetPendingRequest(int request_id); | |
48 void RemoveRequest(int request_id); | |
49 | |
50 ExtensionDispatcher* extension_dispatcher_; | |
51 PendingRequestMap pending_requests_; | |
52 ChromeV8ContextSet* context_set_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(ExtensionRequestSender); | |
55 }; | |
56 | |
57 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_REQUEST_SENDER_H_ | |
OLD | NEW |