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 26 matching lines...) Expand all Loading... |
37 class RenderViewHost; | 37 class RenderViewHost; |
38 class WebContents; | 38 class WebContents; |
39 } | 39 } |
40 | 40 |
41 namespace extensions { | 41 namespace extensions { |
42 class ExtensionFunctionDispatcher; | 42 class ExtensionFunctionDispatcher; |
43 class ExtensionMessageFilter; | 43 class ExtensionMessageFilter; |
44 class QuotaLimitHeuristic; | 44 class QuotaLimitHeuristic; |
45 } | 45 } |
46 | 46 |
| 47 namespace IPC { |
| 48 class Sender; |
| 49 } |
| 50 |
47 #ifdef NDEBUG | 51 #ifdef NDEBUG |
48 #define EXTENSION_FUNCTION_VALIDATE(test) \ | 52 #define EXTENSION_FUNCTION_VALIDATE(test) \ |
49 do { \ | 53 do { \ |
50 if (!(test)) { \ | 54 if (!(test)) { \ |
51 bad_message_ = true; \ | 55 bad_message_ = true; \ |
52 return ValidationFailure(this); \ | 56 return ValidationFailure(this); \ |
53 } \ | 57 } \ |
54 } while (0) | 58 } while (0) |
55 #else // NDEBUG | 59 #else // NDEBUG |
56 #define EXTENSION_FUNCTION_VALIDATE(test) CHECK(test) | 60 #define EXTENSION_FUNCTION_VALIDATE(test) CHECK(test) |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 const std::string& message); | 415 const std::string& message); |
412 | 416 |
413 friend struct content::BrowserThread::DeleteOnThread< | 417 friend struct content::BrowserThread::DeleteOnThread< |
414 content::BrowserThread::UI>; | 418 content::BrowserThread::UI>; |
415 friend class base::DeleteHelper<UIThreadExtensionFunction>; | 419 friend class base::DeleteHelper<UIThreadExtensionFunction>; |
416 | 420 |
417 virtual ~UIThreadExtensionFunction(); | 421 virtual ~UIThreadExtensionFunction(); |
418 | 422 |
419 virtual void SendResponse(bool success) OVERRIDE; | 423 virtual void SendResponse(bool success) OVERRIDE; |
420 | 424 |
| 425 // Sets the Blob UUIDs whose ownership is being transferred to the renderer. |
| 426 void SetTransferredBlobUUIDs(const std::vector<std::string>& blob_uuids); |
| 427 |
421 // The dispatcher that will service this extension function call. | 428 // The dispatcher that will service this extension function call. |
422 base::WeakPtr<extensions::ExtensionFunctionDispatcher> dispatcher_; | 429 base::WeakPtr<extensions::ExtensionFunctionDispatcher> dispatcher_; |
423 | 430 |
424 // The RenderViewHost we will send responses to. | 431 // The RenderViewHost we will send responses to. |
425 content::RenderViewHost* render_view_host_; | 432 content::RenderViewHost* render_view_host_; |
426 | 433 |
427 // The RenderFrameHost we will send responses to. | 434 // The RenderFrameHost we will send responses to. |
428 // NOTE: either render_view_host_ or render_frame_host_ will be set, as we | 435 // NOTE: either render_view_host_ or render_frame_host_ will be set, as we |
429 // port code to use RenderFrames for OOPIF. See http://crbug.com/304341. | 436 // port code to use RenderFrames for OOPIF. See http://crbug.com/304341. |
430 content::RenderFrameHost* render_frame_host_; | 437 content::RenderFrameHost* render_frame_host_; |
431 | 438 |
432 // The content::BrowserContext of this function's extension. | 439 // The content::BrowserContext of this function's extension. |
433 content::BrowserContext* context_; | 440 content::BrowserContext* context_; |
434 | 441 |
435 private: | 442 private: |
436 class RenderHostTracker; | 443 class RenderHostTracker; |
437 | 444 |
438 virtual void Destruct() const OVERRIDE; | 445 virtual void Destruct() const OVERRIDE; |
439 | 446 |
| 447 // TODO(tommycli): Remove once RenderViewHost is gone. |
| 448 IPC::Sender* GetIPCSender(); |
| 449 int GetRoutingID(); |
| 450 |
440 scoped_ptr<RenderHostTracker> tracker_; | 451 scoped_ptr<RenderHostTracker> tracker_; |
441 | 452 |
442 DelegateForTests* delegate_; | 453 DelegateForTests* delegate_; |
| 454 |
| 455 // The blobs transferred to the renderer process. |
| 456 std::vector<std::string> transferred_blob_uuids_; |
443 }; | 457 }; |
444 | 458 |
445 // Extension functions that run on the IO thread. This type of function avoids | 459 // Extension functions that run on the IO thread. This type of function avoids |
446 // a roundtrip to and from the UI thread (because communication with the | 460 // a roundtrip to and from the UI thread (because communication with the |
447 // extension process happens on the IO thread). It's intended to be used when | 461 // extension process happens on the IO thread). It's intended to be used when |
448 // performance is critical (e.g. the webRequest API which can block network | 462 // performance is critical (e.g. the webRequest API which can block network |
449 // requests). Generally, UIThreadExtensionFunction is more appropriate and will | 463 // requests). Generally, UIThreadExtensionFunction is more appropriate and will |
450 // be easier to use and interface with the rest of the browser. | 464 // be easier to use and interface with the rest of the browser. |
451 class IOThreadExtensionFunction : public ExtensionFunction { | 465 class IOThreadExtensionFunction : public ExtensionFunction { |
452 public: | 466 public: |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 virtual bool RunSync() = 0; | 571 virtual bool RunSync() = 0; |
558 | 572 |
559 // ValidationFailure override to match RunSync(). | 573 // ValidationFailure override to match RunSync(). |
560 static bool ValidationFailure(SyncIOThreadExtensionFunction* function); | 574 static bool ValidationFailure(SyncIOThreadExtensionFunction* function); |
561 | 575 |
562 private: | 576 private: |
563 virtual ResponseAction Run() OVERRIDE; | 577 virtual ResponseAction Run() OVERRIDE; |
564 }; | 578 }; |
565 | 579 |
566 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 580 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
OLD | NEW |