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

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

Issue 950023005: [Extensions] Apply WARN_UNUSED_RESULT and final keyword to ExtensionFunctions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // Some legacy APIs do rely on it though, like webstorePrivate. 315 // Some legacy APIs do rely on it though, like webstorePrivate.
316 ResponseValue ErrorWithArguments(scoped_ptr<base::ListValue> args, 316 ResponseValue ErrorWithArguments(scoped_ptr<base::ListValue> args,
317 const std::string& error); 317 const std::string& error);
318 // Bad message. A ResponseValue equivalent to EXTENSION_FUNCTION_VALIDATE(), 318 // Bad message. A ResponseValue equivalent to EXTENSION_FUNCTION_VALIDATE(),
319 // so this will actually kill the renderer and not respond at all. 319 // so this will actually kill the renderer and not respond at all.
320 ResponseValue BadMessage(); 320 ResponseValue BadMessage();
321 321
322 // ResponseActions. 322 // ResponseActions.
323 // 323 //
324 // Respond to the extension immediately with |result|. 324 // Respond to the extension immediately with |result|.
325 ResponseAction RespondNow(ResponseValue result); 325 ResponseAction RespondNow(ResponseValue result) WARN_UNUSED_RESULT;
326 // Don't respond now, but promise to call Respond(...) later. 326 // Don't respond now, but promise to call Respond(...) later.
327 ResponseAction RespondLater(); 327 ResponseAction RespondLater() WARN_UNUSED_RESULT;
328 328
329 // This is the return value of the EXTENSION_FUNCTION_VALIDATE macro, which 329 // This is the return value of the EXTENSION_FUNCTION_VALIDATE macro, which
330 // needs to work from Run(), RunAsync(), and RunSync(). The former of those 330 // needs to work from Run(), RunAsync(), and RunSync(). The former of those
331 // has a different return type (ResponseAction) than the latter two (bool). 331 // has a different return type (ResponseAction) than the latter two (bool).
332 static ResponseAction ValidationFailure(ExtensionFunction* function); 332 static ResponseAction ValidationFailure(ExtensionFunction* function)
333 WARN_UNUSED_RESULT;
333 334
334 // If RespondLater() was used, functions must at some point call Respond() 335 // If RespondLater() was used, functions must at some point call Respond()
335 // with |result| as their result. 336 // with |result| as their result.
336 void Respond(ResponseValue result); 337 void Respond(ResponseValue result);
337 338
338 virtual ~ExtensionFunction(); 339 virtual ~ExtensionFunction();
339 340
340 // Helper method for ExtensionFunctionDeleteTraits. Deletes this object. 341 // Helper method for ExtensionFunctionDeleteTraits. Deletes this object.
341 virtual void Destruct() const = 0; 342 virtual void Destruct() const = 0;
342 343
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 // 582 //
582 // AsyncExtensionFunctions implement this method. Return true to indicate that 583 // AsyncExtensionFunctions implement this method. Return true to indicate that
583 // nothing has gone wrong yet; SendResponse must be called later. Return false 584 // nothing has gone wrong yet; SendResponse must be called later. Return false
584 // to respond immediately with an error. 585 // to respond immediately with an error.
585 virtual bool RunAsync() = 0; 586 virtual bool RunAsync() = 0;
586 587
587 // ValidationFailure override to match RunAsync(). 588 // ValidationFailure override to match RunAsync().
588 static bool ValidationFailure(AsyncExtensionFunction* function); 589 static bool ValidationFailure(AsyncExtensionFunction* function);
589 590
590 private: 591 private:
591 ResponseAction Run() override; 592 ResponseAction Run() final;
592 }; 593 };
593 594
594 // A SyncExtensionFunction is an ExtensionFunction that runs synchronously 595 // A SyncExtensionFunction is an ExtensionFunction that runs synchronously
595 // *relative to the browser's UI thread*. Note that this has nothing to do with 596 // *relative to the browser's UI thread*. Note that this has nothing to do with
596 // running synchronously relative to the extension process. From the extension 597 // running synchronously relative to the extension process. From the extension
597 // process's point of view, the function is still asynchronous. 598 // process's point of view, the function is still asynchronous.
598 // 599 //
599 // This kind of function is convenient for implementing simple APIs that just 600 // This kind of function is convenient for implementing simple APIs that just
600 // need to interact with things on the browser UI thread. 601 // need to interact with things on the browser UI thread.
601 class SyncExtensionFunction : public UIThreadExtensionFunction { 602 class SyncExtensionFunction : public UIThreadExtensionFunction {
602 public: 603 public:
603 SyncExtensionFunction(); 604 SyncExtensionFunction();
604 605
605 protected: 606 protected:
606 ~SyncExtensionFunction() override; 607 ~SyncExtensionFunction() override;
607 608
608 // Deprecated: Override UIThreadExtensionFunction and implement Run() instead. 609 // Deprecated: Override UIThreadExtensionFunction and implement Run() instead.
609 // 610 //
610 // SyncExtensionFunctions implement this method. Return true to respond 611 // SyncExtensionFunctions implement this method. Return true to respond
611 // immediately with success, false to respond immediately with an error. 612 // immediately with success, false to respond immediately with an error.
612 virtual bool RunSync() = 0; 613 virtual bool RunSync() = 0;
613 614
614 // ValidationFailure override to match RunSync(). 615 // ValidationFailure override to match RunSync().
615 static bool ValidationFailure(SyncExtensionFunction* function); 616 static bool ValidationFailure(SyncExtensionFunction* function);
616 617
617 private: 618 private:
618 ResponseAction Run() override; 619 ResponseAction Run() final;
619 }; 620 };
620 621
621 class SyncIOThreadExtensionFunction : public IOThreadExtensionFunction { 622 class SyncIOThreadExtensionFunction : public IOThreadExtensionFunction {
622 public: 623 public:
623 SyncIOThreadExtensionFunction(); 624 SyncIOThreadExtensionFunction();
624 625
625 protected: 626 protected:
626 ~SyncIOThreadExtensionFunction() override; 627 ~SyncIOThreadExtensionFunction() override;
627 628
628 // Deprecated: Override IOThreadExtensionFunction and implement Run() instead. 629 // Deprecated: Override IOThreadExtensionFunction and implement Run() instead.
629 // 630 //
630 // SyncIOThreadExtensionFunctions implement this method. Return true to 631 // SyncIOThreadExtensionFunctions implement this method. Return true to
631 // respond immediately with success, false to respond immediately with an 632 // respond immediately with success, false to respond immediately with an
632 // error. 633 // error.
633 virtual bool RunSync() = 0; 634 virtual bool RunSync() = 0;
634 635
635 // ValidationFailure override to match RunSync(). 636 // ValidationFailure override to match RunSync().
636 static bool ValidationFailure(SyncIOThreadExtensionFunction* function); 637 static bool ValidationFailure(SyncIOThreadExtensionFunction* function);
637 638
638 private: 639 private:
639 ResponseAction Run() override; 640 ResponseAction Run() final;
640 }; 641 };
641 642
642 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 643 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698