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

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

Issue 280393003: Blobs: Catching browser-process created Blobs in extension code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « extensions/browser/blob_holder.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 <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
(...skipping 26 matching lines...) Expand all
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 const std::string& message); 425 const std::string& message);
422 426
423 friend struct content::BrowserThread::DeleteOnThread< 427 friend struct content::BrowserThread::DeleteOnThread<
424 content::BrowserThread::UI>; 428 content::BrowserThread::UI>;
425 friend class base::DeleteHelper<UIThreadExtensionFunction>; 429 friend class base::DeleteHelper<UIThreadExtensionFunction>;
426 430
427 virtual ~UIThreadExtensionFunction(); 431 virtual ~UIThreadExtensionFunction();
428 432
429 virtual void SendResponse(bool success) OVERRIDE; 433 virtual void SendResponse(bool success) OVERRIDE;
430 434
435 // Sets the Blob UUIDs whose ownership is being transferred to the renderer.
436 void SetTransferredBlobUUIDs(const std::vector<std::string>& blob_uuids);
437
431 // The dispatcher that will service this extension function call. 438 // The dispatcher that will service this extension function call.
432 base::WeakPtr<extensions::ExtensionFunctionDispatcher> dispatcher_; 439 base::WeakPtr<extensions::ExtensionFunctionDispatcher> dispatcher_;
433 440
434 // The RenderViewHost we will send responses to. 441 // The RenderViewHost we will send responses to.
435 content::RenderViewHost* render_view_host_; 442 content::RenderViewHost* render_view_host_;
436 443
437 // The RenderFrameHost we will send responses to. 444 // The RenderFrameHost we will send responses to.
438 // NOTE: either render_view_host_ or render_frame_host_ will be set, as we 445 // NOTE: either render_view_host_ or render_frame_host_ will be set, as we
439 // port code to use RenderFrames for OOPIF. See http://crbug.com/304341. 446 // port code to use RenderFrames for OOPIF. See http://crbug.com/304341.
440 content::RenderFrameHost* render_frame_host_; 447 content::RenderFrameHost* render_frame_host_;
441 448
442 // The content::BrowserContext of this function's extension. 449 // The content::BrowserContext of this function's extension.
443 content::BrowserContext* context_; 450 content::BrowserContext* context_;
444 451
445 private: 452 private:
446 class RenderHostTracker; 453 class RenderHostTracker;
447 454
448 virtual void Destruct() const OVERRIDE; 455 virtual void Destruct() const OVERRIDE;
449 456
457 // TODO(tommycli): Remove once RenderViewHost is gone.
458 IPC::Sender* GetIPCSender();
459 int GetRoutingID();
460
450 scoped_ptr<RenderHostTracker> tracker_; 461 scoped_ptr<RenderHostTracker> tracker_;
451 462
452 DelegateForTests* delegate_; 463 DelegateForTests* delegate_;
464
465 // The blobs transferred to the renderer process.
466 std::vector<std::string> transferred_blob_uuids_;
453 }; 467 };
454 468
455 // Extension functions that run on the IO thread. This type of function avoids 469 // Extension functions that run on the IO thread. This type of function avoids
456 // a roundtrip to and from the UI thread (because communication with the 470 // a roundtrip to and from the UI thread (because communication with the
457 // extension process happens on the IO thread). It's intended to be used when 471 // extension process happens on the IO thread). It's intended to be used when
458 // performance is critical (e.g. the webRequest API which can block network 472 // performance is critical (e.g. the webRequest API which can block network
459 // requests). Generally, UIThreadExtensionFunction is more appropriate and will 473 // requests). Generally, UIThreadExtensionFunction is more appropriate and will
460 // be easier to use and interface with the rest of the browser. 474 // be easier to use and interface with the rest of the browser.
461 class IOThreadExtensionFunction : public ExtensionFunction { 475 class IOThreadExtensionFunction : public ExtensionFunction {
462 public: 476 public:
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 virtual bool RunSync() = 0; 581 virtual bool RunSync() = 0;
568 582
569 // ValidationFailure override to match RunSync(). 583 // ValidationFailure override to match RunSync().
570 static bool ValidationFailure(SyncIOThreadExtensionFunction* function); 584 static bool ValidationFailure(SyncIOThreadExtensionFunction* function);
571 585
572 private: 586 private:
573 virtual ResponseAction Run() OVERRIDE; 587 virtual ResponseAction Run() OVERRIDE;
574 }; 588 };
575 589
576 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 590 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
OLDNEW
« no previous file with comments | « extensions/browser/blob_holder.cc ('k') | extensions/browser/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698