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

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

Issue 2166523003: Add ref count to service workers for extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync@tott Created 4 years, 2 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
« no previous file with comments | « extensions/browser/bad_message.cc ('k') | extensions/browser/extension_function.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "content/public/common/console_message_level.h" 23 #include "content/public/common/console_message_level.h"
24 #include "extensions/browser/extension_function_histogram_value.h" 24 #include "extensions/browser/extension_function_histogram_value.h"
25 #include "extensions/browser/info_map.h" 25 #include "extensions/browser/info_map.h"
26 #include "extensions/common/constants.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;
32 class IOThreadExtensionFunction; 33 class IOThreadExtensionFunction;
33 34
34 namespace base { 35 namespace base {
35 class ListValue; 36 class ListValue;
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 512 }
512 513
513 void set_dispatcher(const base::WeakPtr< 514 void set_dispatcher(const base::WeakPtr<
514 extensions::ExtensionFunctionDispatcher>& dispatcher) { 515 extensions::ExtensionFunctionDispatcher>& dispatcher) {
515 dispatcher_ = dispatcher; 516 dispatcher_ = dispatcher;
516 } 517 }
517 extensions::ExtensionFunctionDispatcher* dispatcher() const { 518 extensions::ExtensionFunctionDispatcher* dispatcher() const {
518 return dispatcher_.get(); 519 return dispatcher_.get();
519 } 520 }
520 521
521 void set_is_from_service_worker(bool value) { 522 void set_service_worker_version_id(int64_t version_id) {
522 is_from_service_worker_ = value; 523 service_worker_version_id_ = version_id;
523 } 524 }
524 525
525 // Gets the "current" web contents if any. If there is no associated web 526 // Gets the "current" web contents if any. If there is no associated web
526 // contents then defaults to the foremost one. 527 // contents then defaults to the foremost one.
527 // NOTE: "current" can mean different things in different contexts. You 528 // NOTE: "current" can mean different things in different contexts. You
528 // probably want to use GetSenderWebContents(). 529 // probably want to use GetSenderWebContents().
529 virtual content::WebContents* GetAssociatedWebContents(); 530 virtual content::WebContents* GetAssociatedWebContents();
530 531
531 // Returns the web contents associated with the sending |render_frame_host_|. 532 // Returns the web contents associated with the sending |render_frame_host_|.
532 // This can be null. 533 // This can be null.
(...skipping 17 matching lines...) Expand all
550 551
551 // The BrowserContext of this function's extension. 552 // The BrowserContext of this function's extension.
552 // TODO(devlin): Grr... protected members. Move this to be private. 553 // TODO(devlin): Grr... protected members. Move this to be private.
553 content::BrowserContext* context_; 554 content::BrowserContext* context_;
554 555
555 private: 556 private:
556 class RenderFrameHostTracker; 557 class RenderFrameHostTracker;
557 558
558 void Destruct() const override; 559 void Destruct() const override;
559 560
561 bool is_from_service_worker() const {
562 return service_worker_version_id_ !=
563 extensions::kInvalidServiceWorkerVersionId;
564 }
565
560 // The dispatcher that will service this extension function call. 566 // The dispatcher that will service this extension function call.
561 base::WeakPtr<extensions::ExtensionFunctionDispatcher> dispatcher_; 567 base::WeakPtr<extensions::ExtensionFunctionDispatcher> dispatcher_;
562 568
563 // The RenderFrameHost we will send responses to. 569 // The RenderFrameHost we will send responses to.
564 content::RenderFrameHost* render_frame_host_; 570 content::RenderFrameHost* render_frame_host_;
565 571
566 // Whether or not this ExtensionFunction was called by an extension Service 572 // If this ExtensionFunction was called by an extension Service Worker, then
567 // Worker. 573 // this contains the worker's version id.
568 bool is_from_service_worker_; 574 int64_t service_worker_version_id_;
569 575
570 std::unique_ptr<RenderFrameHostTracker> tracker_; 576 std::unique_ptr<RenderFrameHostTracker> tracker_;
571 577
572 // The blobs transferred to the renderer process. 578 // The blobs transferred to the renderer process.
573 std::vector<std::string> transferred_blob_uuids_; 579 std::vector<std::string> transferred_blob_uuids_;
574 580
575 DISALLOW_COPY_AND_ASSIGN(UIThreadExtensionFunction); 581 DISALLOW_COPY_AND_ASSIGN(UIThreadExtensionFunction);
576 }; 582 };
577 583
578 // Extension functions that run on the IO thread. This type of function avoids 584 // Extension functions that run on the IO thread. This type of function avoids
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 private: 677 private:
672 // If you're hitting a compile error here due to "final" - great! You're 678 // If you're hitting a compile error here due to "final" - great! You're
673 // doing the right thing, you just need to extend UIThreadExtensionFunction 679 // doing the right thing, you just need to extend UIThreadExtensionFunction
674 // instead of AsyncExtensionFunction. 680 // instead of AsyncExtensionFunction.
675 ResponseAction Run() final; 681 ResponseAction Run() final;
676 682
677 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction); 683 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction);
678 }; 684 };
679 685
680 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 686 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
OLDNEW
« no previous file with comments | « extensions/browser/bad_message.cc ('k') | extensions/browser/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698