Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: extensions/browser/extension_function.h

Issue 901573003: Split ExtensionMessageFilter up into a UI thread part and an IO thread part. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // performance is critical (e.g. the webRequest API which can block network 516 // performance is critical (e.g. the webRequest API which can block network
517 // requests). Generally, UIThreadExtensionFunction is more appropriate and will 517 // requests). Generally, UIThreadExtensionFunction is more appropriate and will
518 // be easier to use and interface with the rest of the browser. 518 // be easier to use and interface with the rest of the browser.
519 class IOThreadExtensionFunction : public ExtensionFunction { 519 class IOThreadExtensionFunction : public ExtensionFunction {
520 public: 520 public:
521 IOThreadExtensionFunction(); 521 IOThreadExtensionFunction();
522 522
523 IOThreadExtensionFunction* AsIOThreadExtensionFunction() override; 523 IOThreadExtensionFunction* AsIOThreadExtensionFunction() override;
524 524
525 void set_ipc_sender( 525 void set_ipc_sender(
526 base::WeakPtr<extensions::ExtensionMessageFilter> ipc_sender, 526 base::WeakPtr<extensions::IOThreadExtensionMessageFilter> ipc_sender,
527 int routing_id) { 527 int routing_id) {
528 ipc_sender_ = ipc_sender; 528 ipc_sender_ = ipc_sender;
529 routing_id_ = routing_id; 529 routing_id_ = routing_id;
530 } 530 }
531 531
532 base::WeakPtr<extensions::ExtensionMessageFilter> ipc_sender_weak() const { 532 base::WeakPtr<extensions::IOThreadExtensionMessageFilter> ipc_sender_weak()
533 const {
533 return ipc_sender_; 534 return ipc_sender_;
534 } 535 }
535 536
536 int routing_id() const { return routing_id_; } 537 int routing_id() const { return routing_id_; }
537 538
538 void set_extension_info_map(const extensions::InfoMap* extension_info_map) { 539 void set_extension_info_map(const extensions::InfoMap* extension_info_map) {
539 extension_info_map_ = extension_info_map; 540 extension_info_map_ = extension_info_map;
540 } 541 }
541 const extensions::InfoMap* extension_info_map() const { 542 const extensions::InfoMap* extension_info_map() const {
542 return extension_info_map_.get(); 543 return extension_info_map_.get();
543 } 544 }
544 545
545 protected: 546 protected:
546 friend struct content::BrowserThread::DeleteOnThread< 547 friend struct content::BrowserThread::DeleteOnThread<
547 content::BrowserThread::IO>; 548 content::BrowserThread::IO>;
548 friend class base::DeleteHelper<IOThreadExtensionFunction>; 549 friend class base::DeleteHelper<IOThreadExtensionFunction>;
549 550
550 ~IOThreadExtensionFunction() override; 551 ~IOThreadExtensionFunction() override;
551 552
552 void Destruct() const override; 553 void Destruct() const override;
553 554
554 void SendResponse(bool success) override; 555 void SendResponse(bool success) override;
555 556
556 private: 557 private:
557 base::WeakPtr<extensions::ExtensionMessageFilter> ipc_sender_; 558 base::WeakPtr<extensions::IOThreadExtensionMessageFilter> ipc_sender_;
558 int routing_id_; 559 int routing_id_;
559 560
560 scoped_refptr<const extensions::InfoMap> extension_info_map_; 561 scoped_refptr<const extensions::InfoMap> extension_info_map_;
561 }; 562 };
562 563
563 // Base class for an extension function that runs asynchronously *relative to 564 // Base class for an extension function that runs asynchronously *relative to
564 // the browser's UI thread*. 565 // the browser's UI thread*.
565 class AsyncExtensionFunction : public UIThreadExtensionFunction { 566 class AsyncExtensionFunction : public UIThreadExtensionFunction {
566 public: 567 public:
567 AsyncExtensionFunction(); 568 AsyncExtensionFunction();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 virtual bool RunSync() = 0; 626 virtual bool RunSync() = 0;
626 627
627 // ValidationFailure override to match RunSync(). 628 // ValidationFailure override to match RunSync().
628 static bool ValidationFailure(SyncIOThreadExtensionFunction* function); 629 static bool ValidationFailure(SyncIOThreadExtensionFunction* function);
629 630
630 private: 631 private:
631 ResponseAction Run() override; 632 ResponseAction Run() override;
632 }; 633 };
633 634
634 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 635 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698