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

Side by Side Diff: tools/ipc_fuzzer/fuzzer/fuzzer.cc

Issue 2511403003: Send IndexedDB observations through IDBDatabaseCallbacks. (Closed)
Patch Set: Remove unnecessary forward declaration. Created 4 years 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 | « third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include <iostream> 5 #include <iostream>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); 750 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
751 if (!FuzzParam(render_pass.get(), fuzzer)) 751 if (!FuzzParam(render_pass.get(), fuzzer))
752 return false; 752 return false;
753 p->push_back(std::move(render_pass)); 753 p->push_back(std::move(render_pass));
754 } 754 }
755 return true; 755 return true;
756 } 756 }
757 }; 757 };
758 758
759 template <> 759 template <>
760 struct FuzzTraits<content::IndexedDBKey> {
761 static bool Fuzz(content::IndexedDBKey* p, Fuzzer* fuzzer) {
762 // TODO(mbarbella): Support mutation.
763 if (!fuzzer->ShouldGenerate())
764 return true;
765
766 ++g_depth;
767 blink::WebIDBKeyType web_type =
768 static_cast<blink::WebIDBKeyType>(RandInRange(7));
769 switch (web_type) {
770 case blink::WebIDBKeyTypeArray: {
771 size_t length = g_depth > 3 ? 0 : RandInRange(4);
772 std::vector<content::IndexedDBKey> array;
773 array.resize(length);
774 for (size_t i = 0; i < length; ++i) {
775 if (!FuzzParam(&array[i], fuzzer)) {
776 --g_depth;
777 return false;
778 }
779 }
780 *p = content::IndexedDBKey(array);
781 return true;
782 }
783 case blink::WebIDBKeyTypeBinary: {
784 std::string binary;
785 if (!FuzzParam(&binary, fuzzer)) {
786 --g_depth;
787 return false;
788 }
789 *p = content::IndexedDBKey(binary);
790 return true;
791 }
792 case blink::WebIDBKeyTypeString: {
793 base::string16 string;
794 if (!FuzzParam(&string, fuzzer))
795 return false;
796 *p = content::IndexedDBKey(string);
797 return true;
798 }
799 case blink::WebIDBKeyTypeDate:
800 case blink::WebIDBKeyTypeNumber: {
801 double number;
802 if (!FuzzParam(&number, fuzzer)) {
803 --g_depth;
804 return false;
805 }
806 *p = content::IndexedDBKey(number, web_type);
807 return true;
808 }
809 case blink::WebIDBKeyTypeInvalid:
810 case blink::WebIDBKeyTypeNull: {
811 *p = content::IndexedDBKey(web_type);
812 return true;
813 }
814 default: {
815 NOTREACHED();
816 --g_depth;
817 return false;
818 }
819 }
820 }
821 };
822
823 template <>
824 struct FuzzTraits<content::IndexedDBKeyRange> {
825 static bool Fuzz(content::IndexedDBKeyRange* p, Fuzzer* fuzzer) {
826 content::IndexedDBKey lower = p->lower();
827 content::IndexedDBKey upper = p->upper();
828 bool lower_open = p->lower_open();
829 bool upper_open = p->upper_open();
830 if (!FuzzParam(&lower, fuzzer))
831 return false;
832 if (!FuzzParam(&upper, fuzzer))
833 return false;
834 if (!FuzzParam(&lower_open, fuzzer))
835 return false;
836 if (!FuzzParam(&upper_open, fuzzer))
837 return false;
838 *p = content::IndexedDBKeyRange(lower, upper, lower_open, upper_open);
839 return true;
840 }
841 };
842
843 template <>
844 struct FuzzTraits<content::IndexedDBKeyPath> {
845 static bool Fuzz(content::IndexedDBKeyPath* p, Fuzzer* fuzzer) {
846 // TODO(mbarbella): Support mutation.
847 if (!fuzzer->ShouldGenerate())
848 return true;
849
850 switch (RandInRange(3)) {
851 case 0: {
852 std::vector<base::string16> array;
853 if (!FuzzParam(&array, fuzzer))
854 return false;
855 *p = content::IndexedDBKeyPath(array);
856 break;
857 }
858 case 1: {
859 base::string16 string;
860 if (!FuzzParam(&string, fuzzer))
861 return false;
862 *p = content::IndexedDBKeyPath(string);
863 break;
864 }
865 case 2: {
866 *p = content::IndexedDBKeyPath();
867 break;
868 }
869 }
870 return true;
871 }
872 };
873
874 template <>
875 struct FuzzTraits<content::PageState> { 760 struct FuzzTraits<content::PageState> {
876 static bool Fuzz(content::PageState* p, Fuzzer* fuzzer) { 761 static bool Fuzz(content::PageState* p, Fuzzer* fuzzer) {
877 std::string data = p->ToEncodedData(); 762 std::string data = p->ToEncodedData();
878 if (!FuzzParam(&data, fuzzer)) 763 if (!FuzzParam(&data, fuzzer))
879 return false; 764 return false;
880 *p = content::PageState::CreateFromEncodedData(data); 765 *p = content::PageState::CreateFromEncodedData(data);
881 return true; 766 return true;
882 } 767 }
883 }; 768 };
884 769
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h" 1884 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h"
2000 #undef IPC_MESSAGE_DECL 1885 #undef IPC_MESSAGE_DECL
2001 #define IPC_MESSAGE_DECL(name, ...) \ 1886 #define IPC_MESSAGE_DECL(name, ...) \
2002 (*map)[static_cast<uint32_t>(name::ID)] = FuzzerHelper<name>::Fuzz; 1887 (*map)[static_cast<uint32_t>(name::ID)] = FuzzerHelper<name>::Fuzz;
2003 1888
2004 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map) { 1889 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map) {
2005 #include "tools/ipc_fuzzer/message_lib/all_messages.h" 1890 #include "tools/ipc_fuzzer/message_lib/all_messages.h"
2006 } 1891 }
2007 1892
2008 } // namespace ipc_fuzzer 1893 } // namespace ipc_fuzzer
OLDNEW
« no previous file with comments | « third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698