| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace content { | 35 namespace content { |
| 36 class BrowserContext; | 36 class BrowserContext; |
| 37 class RenderFrameHost; | 37 class RenderFrameHost; |
| 38 class RenderViewHost; | 38 class RenderViewHost; |
| 39 class WebContents; | 39 class WebContents; |
| 40 } | 40 } |
| 41 | 41 |
| 42 namespace extensions { | 42 namespace extensions { |
| 43 class ExtensionFunctionDispatcher; | 43 class ExtensionFunctionDispatcher; |
| 44 class ExtensionMessageFilter; | 44 class IOThreadExtensionMessageFilter; |
| 45 class QuotaLimitHeuristic; | 45 class QuotaLimitHeuristic; |
| 46 } | 46 } |
| 47 | 47 |
| 48 namespace IPC { | 48 namespace IPC { |
| 49 class Sender; | 49 class Sender; |
| 50 } | 50 } |
| 51 | 51 |
| 52 #ifdef NDEBUG | 52 #ifdef NDEBUG |
| 53 #define EXTENSION_FUNCTION_VALIDATE(test) \ | 53 #define EXTENSION_FUNCTION_VALIDATE(test) \ |
| 54 do { \ | 54 do { \ |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // performance is critical (e.g. the webRequest API which can block network | 522 // performance is critical (e.g. the webRequest API which can block network |
| 523 // requests). Generally, UIThreadExtensionFunction is more appropriate and will | 523 // requests). Generally, UIThreadExtensionFunction is more appropriate and will |
| 524 // be easier to use and interface with the rest of the browser. | 524 // be easier to use and interface with the rest of the browser. |
| 525 class IOThreadExtensionFunction : public ExtensionFunction { | 525 class IOThreadExtensionFunction : public ExtensionFunction { |
| 526 public: | 526 public: |
| 527 IOThreadExtensionFunction(); | 527 IOThreadExtensionFunction(); |
| 528 | 528 |
| 529 IOThreadExtensionFunction* AsIOThreadExtensionFunction() override; | 529 IOThreadExtensionFunction* AsIOThreadExtensionFunction() override; |
| 530 | 530 |
| 531 void set_ipc_sender( | 531 void set_ipc_sender( |
| 532 base::WeakPtr<extensions::ExtensionMessageFilter> ipc_sender, | 532 base::WeakPtr<extensions::IOThreadExtensionMessageFilter> ipc_sender, |
| 533 int routing_id) { | 533 int routing_id) { |
| 534 ipc_sender_ = ipc_sender; | 534 ipc_sender_ = ipc_sender; |
| 535 routing_id_ = routing_id; | 535 routing_id_ = routing_id; |
| 536 } | 536 } |
| 537 | 537 |
| 538 base::WeakPtr<extensions::ExtensionMessageFilter> ipc_sender_weak() const { | 538 base::WeakPtr<extensions::IOThreadExtensionMessageFilter> ipc_sender_weak() |
| 539 const { |
| 539 return ipc_sender_; | 540 return ipc_sender_; |
| 540 } | 541 } |
| 541 | 542 |
| 542 int routing_id() const { return routing_id_; } | 543 int routing_id() const { return routing_id_; } |
| 543 | 544 |
| 544 void set_extension_info_map(const extensions::InfoMap* extension_info_map) { | 545 void set_extension_info_map(const extensions::InfoMap* extension_info_map) { |
| 545 extension_info_map_ = extension_info_map; | 546 extension_info_map_ = extension_info_map; |
| 546 } | 547 } |
| 547 const extensions::InfoMap* extension_info_map() const { | 548 const extensions::InfoMap* extension_info_map() const { |
| 548 return extension_info_map_.get(); | 549 return extension_info_map_.get(); |
| 549 } | 550 } |
| 550 | 551 |
| 551 protected: | 552 protected: |
| 552 friend struct content::BrowserThread::DeleteOnThread< | 553 friend struct content::BrowserThread::DeleteOnThread< |
| 553 content::BrowserThread::IO>; | 554 content::BrowserThread::IO>; |
| 554 friend class base::DeleteHelper<IOThreadExtensionFunction>; | 555 friend class base::DeleteHelper<IOThreadExtensionFunction>; |
| 555 | 556 |
| 556 ~IOThreadExtensionFunction() override; | 557 ~IOThreadExtensionFunction() override; |
| 557 | 558 |
| 558 void Destruct() const override; | 559 void Destruct() const override; |
| 559 | 560 |
| 560 void SendResponse(bool success) override; | 561 void SendResponse(bool success) override; |
| 561 | 562 |
| 562 private: | 563 private: |
| 563 base::WeakPtr<extensions::ExtensionMessageFilter> ipc_sender_; | 564 base::WeakPtr<extensions::IOThreadExtensionMessageFilter> ipc_sender_; |
| 564 int routing_id_; | 565 int routing_id_; |
| 565 | 566 |
| 566 scoped_refptr<const extensions::InfoMap> extension_info_map_; | 567 scoped_refptr<const extensions::InfoMap> extension_info_map_; |
| 567 }; | 568 }; |
| 568 | 569 |
| 569 // Base class for an extension function that runs asynchronously *relative to | 570 // Base class for an extension function that runs asynchronously *relative to |
| 570 // the browser's UI thread*. | 571 // the browser's UI thread*. |
| 571 class AsyncExtensionFunction : public UIThreadExtensionFunction { | 572 class AsyncExtensionFunction : public UIThreadExtensionFunction { |
| 572 public: | 573 public: |
| 573 AsyncExtensionFunction(); | 574 AsyncExtensionFunction(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 virtual bool RunSync() = 0; | 632 virtual bool RunSync() = 0; |
| 632 | 633 |
| 633 // ValidationFailure override to match RunSync(). | 634 // ValidationFailure override to match RunSync(). |
| 634 static bool ValidationFailure(SyncIOThreadExtensionFunction* function); | 635 static bool ValidationFailure(SyncIOThreadExtensionFunction* function); |
| 635 | 636 |
| 636 private: | 637 private: |
| 637 ResponseAction Run() override; | 638 ResponseAction Run() override; |
| 638 }; | 639 }; |
| 639 | 640 |
| 640 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 641 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
| OLD | NEW |