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

Side by Side Diff: third_party/WebKit/Source/core/fileapi/FileReaderSync.cpp

Issue 2804403003: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/fileapi (Closed)
Patch Set: fix Created 3 years, 8 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 | « third_party/WebKit/Source/core/fileapi/FileReaderLoaderClient.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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 EnumerationHistogram, worker_type_histogram, 64 EnumerationHistogram, worker_type_histogram,
65 new EnumerationHistogram("FileReaderSync.WorkerType", 65 new EnumerationHistogram("FileReaderSync.WorkerType",
66 static_cast<int>(WorkerType::MAX))); 66 static_cast<int>(WorkerType::MAX)));
67 worker_type_histogram.Count(static_cast<int>(type)); 67 worker_type_histogram.Count(static_cast<int>(type));
68 } 68 }
69 69
70 DOMArrayBuffer* FileReaderSync::readAsArrayBuffer( 70 DOMArrayBuffer* FileReaderSync::readAsArrayBuffer(
71 ScriptState* script_state, 71 ScriptState* script_state,
72 Blob* blob, 72 Blob* blob,
73 ExceptionState& exception_state) { 73 ExceptionState& exception_state) {
74 ASSERT(blob); 74 DCHECK(blob);
75 75
76 std::unique_ptr<FileReaderLoader> loader = 76 std::unique_ptr<FileReaderLoader> loader =
77 FileReaderLoader::Create(FileReaderLoader::kReadAsArrayBuffer, nullptr); 77 FileReaderLoader::Create(FileReaderLoader::kReadAsArrayBuffer, nullptr);
78 StartLoading(script_state->GetExecutionContext(), *loader, *blob, 78 StartLoading(script_state->GetExecutionContext(), *loader, *blob,
79 exception_state); 79 exception_state);
80 80
81 return loader->ArrayBufferResult(); 81 return loader->ArrayBufferResult();
82 } 82 }
83 83
84 String FileReaderSync::readAsBinaryString(ScriptState* script_state, 84 String FileReaderSync::readAsBinaryString(ScriptState* script_state,
85 Blob* blob, 85 Blob* blob,
86 ExceptionState& exception_state) { 86 ExceptionState& exception_state) {
87 ASSERT(blob); 87 DCHECK(blob);
88 88
89 std::unique_ptr<FileReaderLoader> loader = 89 std::unique_ptr<FileReaderLoader> loader =
90 FileReaderLoader::Create(FileReaderLoader::kReadAsBinaryString, nullptr); 90 FileReaderLoader::Create(FileReaderLoader::kReadAsBinaryString, nullptr);
91 StartLoading(script_state->GetExecutionContext(), *loader, *blob, 91 StartLoading(script_state->GetExecutionContext(), *loader, *blob,
92 exception_state); 92 exception_state);
93 return loader->StringResult(); 93 return loader->StringResult();
94 } 94 }
95 95
96 String FileReaderSync::readAsText(ScriptState* script_state, 96 String FileReaderSync::readAsText(ScriptState* script_state,
97 Blob* blob, 97 Blob* blob,
98 const String& encoding, 98 const String& encoding,
99 ExceptionState& exception_state) { 99 ExceptionState& exception_state) {
100 ASSERT(blob); 100 DCHECK(blob);
101 101
102 std::unique_ptr<FileReaderLoader> loader = 102 std::unique_ptr<FileReaderLoader> loader =
103 FileReaderLoader::Create(FileReaderLoader::kReadAsText, nullptr); 103 FileReaderLoader::Create(FileReaderLoader::kReadAsText, nullptr);
104 loader->SetEncoding(encoding); 104 loader->SetEncoding(encoding);
105 StartLoading(script_state->GetExecutionContext(), *loader, *blob, 105 StartLoading(script_state->GetExecutionContext(), *loader, *blob,
106 exception_state); 106 exception_state);
107 return loader->StringResult(); 107 return loader->StringResult();
108 } 108 }
109 109
110 String FileReaderSync::readAsDataURL(ScriptState* script_state, 110 String FileReaderSync::readAsDataURL(ScriptState* script_state,
111 Blob* blob, 111 Blob* blob,
112 ExceptionState& exception_state) { 112 ExceptionState& exception_state) {
113 ASSERT(blob); 113 DCHECK(blob);
114 114
115 std::unique_ptr<FileReaderLoader> loader = 115 std::unique_ptr<FileReaderLoader> loader =
116 FileReaderLoader::Create(FileReaderLoader::kReadAsDataURL, nullptr); 116 FileReaderLoader::Create(FileReaderLoader::kReadAsDataURL, nullptr);
117 loader->SetDataType(blob->type()); 117 loader->SetDataType(blob->type());
118 StartLoading(script_state->GetExecutionContext(), *loader, *blob, 118 StartLoading(script_state->GetExecutionContext(), *loader, *blob,
119 exception_state); 119 exception_state);
120 return loader->StringResult(); 120 return loader->StringResult();
121 } 121 }
122 122
123 void FileReaderSync::StartLoading(ExecutionContext* execution_context, 123 void FileReaderSync::StartLoading(ExecutionContext* execution_context,
124 FileReaderLoader& loader, 124 FileReaderLoader& loader,
125 const Blob& blob, 125 const Blob& blob,
126 ExceptionState& exception_state) { 126 ExceptionState& exception_state) {
127 loader.Start(execution_context, blob.GetBlobDataHandle()); 127 loader.Start(execution_context, blob.GetBlobDataHandle());
128 if (loader.GetErrorCode()) 128 if (loader.GetErrorCode())
129 FileError::ThrowDOMException(exception_state, loader.GetErrorCode()); 129 FileError::ThrowDOMException(exception_state, loader.GetErrorCode());
130 } 130 }
131 131
132 } // namespace blink 132 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fileapi/FileReaderLoaderClient.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698