| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/process/process.h" | 19 #include "base/process/process.h" |
| 20 #include "base/sequenced_task_runner_helpers.h" | 20 #include "base/sequenced_task_runner_helpers.h" |
| 21 #include "base/timer/elapsed_timer.h" | 21 #include "base/timer/elapsed_timer.h" |
| 22 #include "content/common/service_worker/service_worker_types.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/common/console_message_level.h" | 24 #include "content/public/common/console_message_level.h" |
| 24 #include "extensions/browser/extension_function_histogram_value.h" | 25 #include "extensions/browser/extension_function_histogram_value.h" |
| 25 #include "extensions/browser/info_map.h" | 26 #include "extensions/browser/info_map.h" |
| 26 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
| 27 #include "extensions/common/features/feature.h" | 28 #include "extensions/common/features/feature.h" |
| 28 #include "ipc/ipc_message.h" | 29 #include "ipc/ipc_message.h" |
| 29 | 30 |
| 30 class ExtensionFunction; | 31 class ExtensionFunction; |
| 31 class UIThreadExtensionFunction; | 32 class UIThreadExtensionFunction; |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } | 516 } |
| 516 | 517 |
| 517 void set_dispatcher(const base::WeakPtr< | 518 void set_dispatcher(const base::WeakPtr< |
| 518 extensions::ExtensionFunctionDispatcher>& dispatcher) { | 519 extensions::ExtensionFunctionDispatcher>& dispatcher) { |
| 519 dispatcher_ = dispatcher; | 520 dispatcher_ = dispatcher; |
| 520 } | 521 } |
| 521 extensions::ExtensionFunctionDispatcher* dispatcher() const { | 522 extensions::ExtensionFunctionDispatcher* dispatcher() const { |
| 522 return dispatcher_.get(); | 523 return dispatcher_.get(); |
| 523 } | 524 } |
| 524 | 525 |
| 525 void set_is_from_service_worker(bool value) { | 526 void set_service_worker_version_id(int64_t version_id) { |
| 526 is_from_service_worker_ = value; | 527 service_worker_version_id_ = version_id; |
| 527 } | 528 } |
| 528 | 529 |
| 529 // Gets the "current" web contents if any. If there is no associated web | 530 // Gets the "current" web contents if any. If there is no associated web |
| 530 // contents then defaults to the foremost one. | 531 // contents then defaults to the foremost one. |
| 531 // NOTE: "current" can mean different things in different contexts. You | 532 // NOTE: "current" can mean different things in different contexts. You |
| 532 // probably want to use GetSenderWebContents(). | 533 // probably want to use GetSenderWebContents(). |
| 533 virtual content::WebContents* GetAssociatedWebContents(); | 534 virtual content::WebContents* GetAssociatedWebContents(); |
| 534 | 535 |
| 535 // Returns the web contents associated with the sending |render_frame_host_|. | 536 // Returns the web contents associated with the sending |render_frame_host_|. |
| 536 // This can be null. | 537 // This can be null. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 554 | 555 |
| 555 // The BrowserContext of this function's extension. | 556 // The BrowserContext of this function's extension. |
| 556 // TODO(devlin): Grr... protected members. Move this to be private. | 557 // TODO(devlin): Grr... protected members. Move this to be private. |
| 557 content::BrowserContext* context_; | 558 content::BrowserContext* context_; |
| 558 | 559 |
| 559 private: | 560 private: |
| 560 class RenderFrameHostTracker; | 561 class RenderFrameHostTracker; |
| 561 | 562 |
| 562 void Destruct() const override; | 563 void Destruct() const override; |
| 563 | 564 |
| 565 bool is_from_service_worker() const { |
| 566 return content::kInvalidServiceWorkerVersionId != |
| 567 service_worker_version_id_; |
| 568 } |
| 569 |
| 564 // The dispatcher that will service this extension function call. | 570 // The dispatcher that will service this extension function call. |
| 565 base::WeakPtr<extensions::ExtensionFunctionDispatcher> dispatcher_; | 571 base::WeakPtr<extensions::ExtensionFunctionDispatcher> dispatcher_; |
| 566 | 572 |
| 567 // The RenderFrameHost we will send responses to. | 573 // The RenderFrameHost we will send responses to. |
| 568 content::RenderFrameHost* render_frame_host_; | 574 content::RenderFrameHost* render_frame_host_; |
| 569 | 575 |
| 570 // Whether or not this ExtensionFunction was called by an extension Service | 576 // If this ExtensionFunction was called by an extension Service Worker, then |
| 571 // Worker. | 577 // this contains the worker's version id. |
| 572 bool is_from_service_worker_; | 578 int64_t service_worker_version_id_; |
| 573 | 579 |
| 574 std::unique_ptr<RenderFrameHostTracker> tracker_; | 580 std::unique_ptr<RenderFrameHostTracker> tracker_; |
| 575 | 581 |
| 576 // The blobs transferred to the renderer process. | 582 // The blobs transferred to the renderer process. |
| 577 std::vector<std::string> transferred_blob_uuids_; | 583 std::vector<std::string> transferred_blob_uuids_; |
| 578 | 584 |
| 579 DISALLOW_COPY_AND_ASSIGN(UIThreadExtensionFunction); | 585 DISALLOW_COPY_AND_ASSIGN(UIThreadExtensionFunction); |
| 580 }; | 586 }; |
| 581 | 587 |
| 582 // Extension functions that run on the IO thread. This type of function avoids | 588 // Extension functions that run on the IO thread. This type of function avoids |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 private: | 680 private: |
| 675 // If you're hitting a compile error here due to "final" - great! You're | 681 // If you're hitting a compile error here due to "final" - great! You're |
| 676 // doing the right thing, you just need to extend UIThreadExtensionFunction | 682 // doing the right thing, you just need to extend UIThreadExtensionFunction |
| 677 // instead of AsyncExtensionFunction. | 683 // instead of AsyncExtensionFunction. |
| 678 ResponseAction Run() final; | 684 ResponseAction Run() final; |
| 679 | 685 |
| 680 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction); | 686 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction); |
| 681 }; | 687 }; |
| 682 | 688 |
| 683 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 689 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
| OLD | NEW |