OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_RENDERER_EXTENSIONS_REQUEST_SENDER_H_ | 5 #ifndef EXTENSIONS_RENDERER_REQUEST_SENDER_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_REQUEST_SENDER_H_ | 6 #define EXTENSIONS_RENDERER_REQUEST_SENDER_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <string> | 9 #include <string> |
9 #include <map> | |
10 | 10 |
11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
12 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class ListValue; | 15 class ListValue; |
16 } | 16 } |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 class ChromeV8Context; | |
20 class Dispatcher; | 19 class Dispatcher; |
| 20 class ScriptContext; |
21 | 21 |
22 struct PendingRequest; | 22 struct PendingRequest; |
23 | 23 |
24 // Responsible for sending requests for named extension API functions to the | 24 // Responsible for sending requests for named extension API functions to the |
25 // extension host and routing the responses back to the caller. | 25 // extension host and routing the responses back to the caller. |
26 class RequestSender { | 26 class RequestSender { |
27 public: | 27 public: |
28 // Source represents a user of RequestSender. Every request is associated with | 28 // Source represents a user of RequestSender. Every request is associated with |
29 // a Source object, which will be notified when the corresponding response | 29 // a Source object, which will be notified when the corresponding response |
30 // arrives. When a Source object is going away and there are pending requests, | 30 // arrives. When a Source object is going away and there are pending requests, |
31 // it should call InvalidateSource() to make sure no notifications are sent to | 31 // it should call InvalidateSource() to make sure no notifications are sent to |
32 // it later. | 32 // it later. |
33 class Source { | 33 class Source { |
34 public: | 34 public: |
35 virtual ~Source() {} | 35 virtual ~Source() {} |
36 | 36 |
37 virtual ChromeV8Context* GetContext() = 0; | 37 virtual ScriptContext* GetContext() = 0; |
38 virtual void OnResponseReceived(const std::string& name, | 38 virtual void OnResponseReceived(const std::string& name, |
39 int request_id, | 39 int request_id, |
40 bool success, | 40 bool success, |
41 const base::ListValue& response, | 41 const base::ListValue& response, |
42 const std::string& error) = 0; | 42 const std::string& error) = 0; |
43 }; | 43 }; |
44 | 44 |
45 // Helper class to (re)set the |source_tab_id_| below. | 45 // Helper class to (re)set the |source_tab_id_| below. |
46 class ScopedTabID { | 46 class ScopedTabID { |
47 public: | 47 public: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 Dispatcher* dispatcher_; | 96 Dispatcher* dispatcher_; |
97 PendingRequestMap pending_requests_; | 97 PendingRequestMap pending_requests_; |
98 | 98 |
99 int source_tab_id_; // Id of the tab sending the request, or -1 if no tab. | 99 int source_tab_id_; // Id of the tab sending the request, or -1 if no tab. |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(RequestSender); | 101 DISALLOW_COPY_AND_ASSIGN(RequestSender); |
102 }; | 102 }; |
103 | 103 |
104 } // namespace extensions | 104 } // namespace extensions |
105 | 105 |
106 #endif // CHROME_RENDERER_EXTENSIONS_REQUEST_SENDER_H_ | 106 #endif // EXTENSIONS_RENDERER_REQUEST_SENDER_H_ |
OLD | NEW |