OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... | |
28 class UIThreadExtensionFunction; | 28 class UIThreadExtensionFunction; |
29 class IOThreadExtensionFunction; | 29 class IOThreadExtensionFunction; |
30 | 30 |
31 namespace base { | 31 namespace base { |
32 class ListValue; | 32 class ListValue; |
33 class Value; | 33 class Value; |
34 } | 34 } |
35 | 35 |
36 namespace content { | 36 namespace content { |
37 class BrowserContext; | 37 class BrowserContext; |
38 class RenderFrameHost; | |
38 class RenderViewHost; | 39 class RenderViewHost; |
39 class WebContents; | 40 class WebContents; |
40 } | 41 } |
41 | 42 |
42 namespace extensions { | 43 namespace extensions { |
43 class QuotaLimitHeuristic; | 44 class QuotaLimitHeuristic; |
44 } | 45 } |
45 | 46 |
46 #ifdef NDEBUG | 47 #ifdef NDEBUG |
47 #define EXTENSION_FUNCTION_VALIDATE(test) do { \ | 48 #define EXTENSION_FUNCTION_VALIDATE(test) do { \ |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 UIThreadExtensionFunction(); | 284 UIThreadExtensionFunction(); |
284 | 285 |
285 virtual UIThreadExtensionFunction* AsUIThreadExtensionFunction() OVERRIDE; | 286 virtual UIThreadExtensionFunction* AsUIThreadExtensionFunction() OVERRIDE; |
286 | 287 |
287 void set_test_delegate(DelegateForTests* delegate) { | 288 void set_test_delegate(DelegateForTests* delegate) { |
288 delegate_ = delegate; | 289 delegate_ = delegate; |
289 } | 290 } |
290 | 291 |
291 // Called when a message was received. | 292 // Called when a message was received. |
292 // Should return true if it processed the message. | 293 // Should return true if it processed the message. |
293 virtual bool OnMessageReceivedFromRenderView(const IPC::Message& message); | 294 virtual bool OnMessageReceived(const IPC::Message& message); |
294 | 295 |
295 // Set the browser context which contains the extension that has originated | 296 // Set the browser context which contains the extension that has originated |
296 // this function call. | 297 // this function call. |
297 void set_context(content::BrowserContext* context) { context_ = context; } | 298 void set_context(content::BrowserContext* context) { context_ = context; } |
298 content::BrowserContext* context() const { return context_; } | 299 content::BrowserContext* context() const { return context_; } |
299 | 300 |
300 void SetRenderViewHost(content::RenderViewHost* render_view_host); | 301 void SetRenderViewHost(content::RenderViewHost* render_view_host); |
301 content::RenderViewHost* render_view_host() const { | 302 content::RenderViewHost* render_view_host() const { |
302 return render_view_host_; | 303 return render_view_host_; |
303 } | 304 } |
305 void SetRenderFrameHost(content::RenderFrameHost* render_frame_host); | |
306 content::RenderFrameHost* render_frame_host() const { | |
307 return render_frame_host_; | |
308 } | |
304 | 309 |
305 void set_dispatcher( | 310 void set_dispatcher( |
306 const base::WeakPtr<ExtensionFunctionDispatcher>& dispatcher) { | 311 const base::WeakPtr<ExtensionFunctionDispatcher>& dispatcher) { |
307 dispatcher_ = dispatcher; | 312 dispatcher_ = dispatcher; |
308 } | 313 } |
309 ExtensionFunctionDispatcher* dispatcher() const { | 314 ExtensionFunctionDispatcher* dispatcher() const { |
310 return dispatcher_.get(); | 315 return dispatcher_.get(); |
311 } | 316 } |
312 | 317 |
313 // Gets the "current" web contents if any. If there is no associated web | 318 // Gets the "current" web contents if any. If there is no associated web |
(...skipping 12 matching lines...) Expand all Loading... | |
326 virtual ~UIThreadExtensionFunction(); | 331 virtual ~UIThreadExtensionFunction(); |
327 | 332 |
328 virtual void SendResponse(bool success) OVERRIDE; | 333 virtual void SendResponse(bool success) OVERRIDE; |
329 | 334 |
330 // The dispatcher that will service this extension function call. | 335 // The dispatcher that will service this extension function call. |
331 base::WeakPtr<ExtensionFunctionDispatcher> dispatcher_; | 336 base::WeakPtr<ExtensionFunctionDispatcher> dispatcher_; |
332 | 337 |
333 // The RenderViewHost we will send responses too. | 338 // The RenderViewHost we will send responses too. |
334 content::RenderViewHost* render_view_host_; | 339 content::RenderViewHost* render_view_host_; |
335 | 340 |
341 // The RenderFrameHost we will send responses too. | |
Yoyo Zhou
2013/12/20 00:28:37
nit: to (here and 338)
jam
2013/12/20 17:00:48
Done.
| |
342 // NOTE: either render_view_host_ or render_frame_host_ will be set, as we | |
343 // port code to use RenderFrames for OOPIF. See http://crbug.com/304341. | |
344 content::RenderFrameHost* render_frame_host_; | |
345 | |
336 // The content::BrowserContext of this function's extension. | 346 // The content::BrowserContext of this function's extension. |
337 content::BrowserContext* context_; | 347 content::BrowserContext* context_; |
338 | 348 |
339 private: | 349 private: |
340 class RenderViewHostTracker; | 350 class RenderHostTracker; |
341 | 351 |
342 virtual void Destruct() const OVERRIDE; | 352 virtual void Destruct() const OVERRIDE; |
343 | 353 |
344 scoped_ptr<RenderViewHostTracker> tracker_; | 354 scoped_ptr<RenderHostTracker> tracker_; |
345 | 355 |
346 DelegateForTests* delegate_; | 356 DelegateForTests* delegate_; |
347 }; | 357 }; |
348 | 358 |
349 // Extension functions that run on the IO thread. This type of function avoids | 359 // Extension functions that run on the IO thread. This type of function avoids |
350 // a roundtrip to and from the UI thread (because communication with the | 360 // a roundtrip to and from the UI thread (because communication with the |
351 // extension process happens on the IO thread). It's intended to be used when | 361 // extension process happens on the IO thread). It's intended to be used when |
352 // performance is critical (e.g. the webRequest API which can block network | 362 // performance is critical (e.g. the webRequest API which can block network |
353 // requests). Generally, UIThreadExtensionFunction is more appropriate and will | 363 // requests). Generally, UIThreadExtensionFunction is more appropriate and will |
354 // be easier to use and interface with the rest of the browser. | 364 // be easier to use and interface with the rest of the browser. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 public: | 436 public: |
427 SyncIOThreadExtensionFunction(); | 437 SyncIOThreadExtensionFunction(); |
428 | 438 |
429 virtual void Run() OVERRIDE; | 439 virtual void Run() OVERRIDE; |
430 | 440 |
431 protected: | 441 protected: |
432 virtual ~SyncIOThreadExtensionFunction(); | 442 virtual ~SyncIOThreadExtensionFunction(); |
433 }; | 443 }; |
434 | 444 |
435 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 445 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
OLD | NEW |