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

Side by Side Diff: third_party/WebKit/Source/modules/filesystem/InspectorFileSystemAgent.cpp

Issue 1702673002: DevTools: migrate remote debugging protocol generators to jinja2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "modules/filesystem/Metadata.h" 58 #include "modules/filesystem/Metadata.h"
59 #include "modules/filesystem/MetadataCallback.h" 59 #include "modules/filesystem/MetadataCallback.h"
60 #include "platform/ContentType.h" 60 #include "platform/ContentType.h"
61 #include "platform/MIMETypeRegistry.h" 61 #include "platform/MIMETypeRegistry.h"
62 #include "platform/heap/Handle.h" 62 #include "platform/heap/Handle.h"
63 #include "platform/weborigin/KURL.h" 63 #include "platform/weborigin/KURL.h"
64 #include "platform/weborigin/SecurityOrigin.h" 64 #include "platform/weborigin/SecurityOrigin.h"
65 #include "wtf/text/Base64.h" 65 #include "wtf/text/Base64.h"
66 #include "wtf/text/TextEncoding.h" 66 #include "wtf/text/TextEncoding.h"
67 67
68 using blink::protocol::TypeBuilder::Array;
69
70 typedef blink::protocol::Dispatcher::FileSystemCommandHandler::RequestFileSystem RootCallback RequestFileSystemRootCallback; 68 typedef blink::protocol::Dispatcher::FileSystemCommandHandler::RequestFileSystem RootCallback RequestFileSystemRootCallback;
71 typedef blink::protocol::Dispatcher::FileSystemCommandHandler::RequestDirectoryC ontentCallback RequestDirectoryContentCallback; 69 typedef blink::protocol::Dispatcher::FileSystemCommandHandler::RequestDirectoryC ontentCallback RequestDirectoryContentCallback;
72 typedef blink::protocol::Dispatcher::FileSystemCommandHandler::RequestMetadataCa llback RequestMetadataCallback; 70 typedef blink::protocol::Dispatcher::FileSystemCommandHandler::RequestMetadataCa llback RequestMetadataCallback;
73 typedef blink::protocol::Dispatcher::FileSystemCommandHandler::RequestFileConten tCallback RequestFileContentCallback; 71 typedef blink::protocol::Dispatcher::FileSystemCommandHandler::RequestFileConten tCallback RequestFileContentCallback;
74 typedef blink::protocol::Dispatcher::FileSystemCommandHandler::DeleteEntryCallba ck DeleteEntryCallback; 72 typedef blink::protocol::Dispatcher::FileSystemCommandHandler::DeleteEntryCallba ck DeleteEntryCallback;
75 73
76 namespace blink { 74 namespace blink {
77 75
76 using namespace protocol;
77 using TypeBuilder::Array;
78
78 namespace FileSystemAgentState { 79 namespace FileSystemAgentState {
79 static const char fileSystemAgentEnabled[] = "fileSystemAgentEnabled"; 80 static const char fileSystemAgentEnabled[] = "fileSystemAgentEnabled";
80 } 81 }
81 82
82 namespace { 83 namespace {
83 84
84 template<typename BaseCallback, typename Handler, typename Argument> 85 template<typename BaseCallback, typename Handler, typename Argument>
85 class GC_PLUGIN_IGNORE("crbug.com/513077") CallbackDispatcher final : public Bas eCallback { 86 class GC_PLUGIN_IGNORE("crbug.com/513077") CallbackDispatcher final : public Bas eCallback {
86 public: 87 public:
87 typedef bool (Handler::*HandlingMethod)(Argument); 88 typedef bool (Handler::*HandlingMethod)(Argument);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 138
138 private: 139 private:
139 bool didHitError(FileError* error) 140 bool didHitError(FileError* error)
140 { 141 {
141 reportResult(error->code()); 142 reportResult(error->code());
142 return true; 143 return true;
143 } 144 }
144 145
145 bool didGetEntry(Entry*); 146 bool didGetEntry(Entry*);
146 147
147 void reportResult(FileError::ErrorCode errorCode, PassRefPtr<protocol::TypeB uilder::FileSystem::Entry> entry = nullptr) 148 void reportResult(FileError::ErrorCode errorCode, PassOwnPtr<protocol::TypeB uilder::FileSystem::Entry> entry = nullptr)
148 { 149 {
149 m_requestCallback->sendSuccess(static_cast<int>(errorCode), entry); 150 m_requestCallback->sendSuccess(static_cast<int>(errorCode), entry);
150 } 151 }
151 152
152 FileSystemRootRequest(PassRefPtr<RequestFileSystemRootCallback> requestCallb ack, const String& type) 153 FileSystemRootRequest(PassRefPtr<RequestFileSystemRootCallback> requestCallb ack, const String& type)
153 : m_requestCallback(requestCallback) 154 : m_requestCallback(requestCallback)
154 , m_type(type) { } 155 , m_type(type) { }
155 156
156 RefPtr<RequestFileSystemRootCallback> m_requestCallback; 157 RefPtr<RequestFileSystemRootCallback> m_requestCallback;
157 String m_type; 158 String m_type;
(...skipping 17 matching lines...) Expand all
175 return; 176 return;
176 } 177 }
177 178
178 EntryCallback* successCallback = CallbackDispatcherFactory<EntryCallback>::c reate(this, &FileSystemRootRequest::didGetEntry); 179 EntryCallback* successCallback = CallbackDispatcherFactory<EntryCallback>::c reate(this, &FileSystemRootRequest::didGetEntry);
179 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks:: create(successCallback, errorCallback, executionContext); 180 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks:: create(successCallback, errorCallback, executionContext);
180 LocalFileSystem::from(*executionContext)->resolveURL(executionContext, rootU RL, fileSystemCallbacks.release()); 181 LocalFileSystem::from(*executionContext)->resolveURL(executionContext, rootU RL, fileSystemCallbacks.release());
181 } 182 }
182 183
183 bool FileSystemRootRequest::didGetEntry(Entry* entry) 184 bool FileSystemRootRequest::didGetEntry(Entry* entry)
184 { 185 {
185 RefPtr<protocol::TypeBuilder::FileSystem::Entry> result = protocol::TypeBuil der::FileSystem::Entry::create() 186 OwnPtr<protocol::TypeBuilder::FileSystem::Entry> result = protocol::TypeBuil der::FileSystem::Entry::create()
186 .setUrl(entry->toURL()) 187 .setUrl(entry->toURL())
187 .setName("/") 188 .setName("/")
188 .setIsDirectory(true); 189 .setIsDirectory(true).build();
189 reportResult(static_cast<FileError::ErrorCode>(0), result); 190 reportResult(static_cast<FileError::ErrorCode>(0), result.release());
190 return true; 191 return true;
191 } 192 }
192 193
193 class DirectoryContentRequest final : public RefCountedWillBeGarbageCollectedFin alized<DirectoryContentRequest> { 194 class DirectoryContentRequest final : public RefCountedWillBeGarbageCollectedFin alized<DirectoryContentRequest> {
194 WTF_MAKE_NONCOPYABLE(DirectoryContentRequest); 195 WTF_MAKE_NONCOPYABLE(DirectoryContentRequest);
195 public: 196 public:
196 static PassRefPtrWillBeRawPtr<DirectoryContentRequest> create(PassRefPtr<Req uestDirectoryContentCallback> requestCallback, const String& url) 197 static PassRefPtrWillBeRawPtr<DirectoryContentRequest> create(PassRefPtr<Req uestDirectoryContentCallback> requestCallback, const String& url)
197 { 198 {
198 return adoptRefWillBeNoop(new DirectoryContentRequest(requestCallback, u rl)); 199 return adoptRefWillBeNoop(new DirectoryContentRequest(requestCallback, u rl));
199 } 200 }
(...skipping 12 matching lines...) Expand all
212 private: 213 private:
213 bool didHitError(FileError* error) 214 bool didHitError(FileError* error)
214 { 215 {
215 reportResult(error->code()); 216 reportResult(error->code());
216 return true; 217 return true;
217 } 218 }
218 219
219 bool didGetEntry(Entry*); 220 bool didGetEntry(Entry*);
220 bool didReadDirectoryEntries(const EntryHeapVector&); 221 bool didReadDirectoryEntries(const EntryHeapVector&);
221 222
222 void reportResult(FileError::ErrorCode errorCode, PassRefPtr<Array<protocol: :TypeBuilder::FileSystem::Entry>> entries = nullptr) 223 void reportResult(FileError::ErrorCode errorCode, PassOwnPtr<Array<protocol: :TypeBuilder::FileSystem::Entry>> entries = nullptr)
223 { 224 {
224 m_requestCallback->sendSuccess(static_cast<int>(errorCode), entries); 225 m_requestCallback->sendSuccess(static_cast<int>(errorCode), entries);
225 } 226 }
226 227
227 DirectoryContentRequest(PassRefPtr<RequestDirectoryContentCallback> requestC allback, const String& url) 228 DirectoryContentRequest(PassRefPtr<RequestDirectoryContentCallback> requestC allback, const String& url)
228 : m_requestCallback(requestCallback) 229 : m_requestCallback(requestCallback)
229 , m_url(ParsedURLString, url) { } 230 , m_url(ParsedURLString, url) { }
230 231
231 void readDirectoryEntries(); 232 void readDirectoryEntries();
232 233
233 RefPtr<RequestDirectoryContentCallback> m_requestCallback; 234 RefPtr<RequestDirectoryContentCallback> m_requestCallback;
234 KURL m_url; 235 KURL m_url;
235 RefPtr<Array<protocol::TypeBuilder::FileSystem::Entry>> m_entries; 236 OwnPtr<Array<protocol::TypeBuilder::FileSystem::Entry>> m_entries;
236 PersistentWillBeMember<DirectoryReader> m_directoryReader; 237 PersistentWillBeMember<DirectoryReader> m_directoryReader;
237 }; 238 };
238 239
239 void DirectoryContentRequest::start(ExecutionContext* executionContext) 240 void DirectoryContentRequest::start(ExecutionContext* executionContext)
240 { 241 {
241 ASSERT(executionContext); 242 ASSERT(executionContext);
242 243
243 ErrorCallback* errorCallback = CallbackDispatcherFactory<ErrorCallback>::cre ate(this, &DirectoryContentRequest::didHitError); 244 ErrorCallback* errorCallback = CallbackDispatcherFactory<ErrorCallback>::cre ate(this, &DirectoryContentRequest::didHitError);
244 EntryCallback* successCallback = CallbackDispatcherFactory<EntryCallback>::c reate(this, &DirectoryContentRequest::didGetEntry); 245 EntryCallback* successCallback = CallbackDispatcherFactory<EntryCallback>::c reate(this, &DirectoryContentRequest::didGetEntry);
245 246
(...skipping 23 matching lines...) Expand all
269 } 270 }
270 271
271 EntriesCallback* successCallback = CallbackDispatcherFactory<EntriesCallback >::create(this, &DirectoryContentRequest::didReadDirectoryEntries); 272 EntriesCallback* successCallback = CallbackDispatcherFactory<EntriesCallback >::create(this, &DirectoryContentRequest::didReadDirectoryEntries);
272 ErrorCallback* errorCallback = CallbackDispatcherFactory<ErrorCallback>::cre ate(this, &DirectoryContentRequest::didHitError); 273 ErrorCallback* errorCallback = CallbackDispatcherFactory<ErrorCallback>::cre ate(this, &DirectoryContentRequest::didHitError);
273 m_directoryReader->readEntries(successCallback, errorCallback); 274 m_directoryReader->readEntries(successCallback, errorCallback);
274 } 275 }
275 276
276 bool DirectoryContentRequest::didReadDirectoryEntries(const EntryHeapVector& ent ries) 277 bool DirectoryContentRequest::didReadDirectoryEntries(const EntryHeapVector& ent ries)
277 { 278 {
278 if (entries.isEmpty()) { 279 if (entries.isEmpty()) {
279 reportResult(static_cast<FileError::ErrorCode>(0), m_entries); 280 reportResult(static_cast<FileError::ErrorCode>(0), m_entries.release());
280 return true; 281 return true;
281 } 282 }
282 283
283 for (size_t i = 0; i < entries.size(); ++i) { 284 for (size_t i = 0; i < entries.size(); ++i) {
284 Entry* entry = entries[i]; 285 Entry* entry = entries[i];
285 RefPtr<protocol::TypeBuilder::FileSystem::Entry> entryForFrontend = prot ocol::TypeBuilder::FileSystem::Entry::create() 286 OwnPtr<protocol::TypeBuilder::FileSystem::Entry> entryForFrontend = prot ocol::TypeBuilder::FileSystem::Entry::create()
286 .setUrl(entry->toURL()) 287 .setUrl(entry->toURL())
287 .setName(entry->name()) 288 .setName(entry->name())
288 .setIsDirectory(entry->isDirectory()); 289 .setIsDirectory(entry->isDirectory()).build();
289
290 using protocol::TypeBuilder::Page::ResourceType;
291 if (!entry->isDirectory()) { 290 if (!entry->isDirectory()) {
292 String mimeType = MIMETypeRegistry::getMIMETypeForPath(entry->name() ); 291 String mimeType = MIMETypeRegistry::getMIMETypeForPath(entry->name() );
293 ResourceType::Enum resourceType; 292 String resourceType;
294 if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) { 293 if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) {
295 resourceType = ResourceType::Image; 294 resourceType = TypeBuilder::Page::ResourceTypeEnum::Image;
296 entryForFrontend->setIsTextFile(false); 295 entryForFrontend->setIsTextFile(false);
297 } else if (HTMLMediaElement::supportsType(ContentType(mimeType)) != WebMimeRegistry::IsNotSupported) { 296 } else if (HTMLMediaElement::supportsType(ContentType(mimeType)) != WebMimeRegistry::IsNotSupported) {
298 resourceType = ResourceType::Media; 297 resourceType = TypeBuilder::Page::ResourceTypeEnum::Media;
299 entryForFrontend->setIsTextFile(false); 298 entryForFrontend->setIsTextFile(false);
300 } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) ) { 299 } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) ) {
301 resourceType = ResourceType::Script; 300 resourceType = TypeBuilder::Page::ResourceTypeEnum::Script;
302 entryForFrontend->setIsTextFile(true); 301 entryForFrontend->setIsTextFile(true);
303 } else if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) { 302 } else if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) {
304 resourceType = ResourceType::Document; 303 resourceType = TypeBuilder::Page::ResourceTypeEnum::Document;
305 entryForFrontend->setIsTextFile(true); 304 entryForFrontend->setIsTextFile(true);
306 } else { 305 } else {
307 resourceType = ResourceType::Other; 306 resourceType = TypeBuilder::Page::ResourceTypeEnum::Other;
308 entryForFrontend->setIsTextFile(DOMImplementation::isXMLMIMEType (mimeType) || DOMImplementation::isTextMIMEType(mimeType)); 307 entryForFrontend->setIsTextFile(DOMImplementation::isXMLMIMEType (mimeType) || DOMImplementation::isTextMIMEType(mimeType));
309 } 308 }
310 309
311 entryForFrontend->setMimeType(mimeType); 310 entryForFrontend->setMimeType(mimeType);
312 entryForFrontend->setResourceType(resourceType); 311 entryForFrontend->setResourceType(resourceType);
313 } 312 }
314 313
315 m_entries->addItem(entryForFrontend); 314 m_entries->addItem(entryForFrontend.release());
316 } 315 }
317 readDirectoryEntries(); 316 readDirectoryEntries();
318 return true; 317 return true;
319 } 318 }
320 319
321 class MetadataRequest final : public RefCountedWillBeGarbageCollectedFinalized<M etadataRequest> { 320 class MetadataRequest final : public RefCountedWillBeGarbageCollectedFinalized<M etadataRequest> {
322 WTF_MAKE_NONCOPYABLE(MetadataRequest); 321 WTF_MAKE_NONCOPYABLE(MetadataRequest);
323 public: 322 public:
324 static PassRefPtrWillBeRawPtr<MetadataRequest> create(PassRefPtr<RequestMeta dataCallback> requestCallback, const String& url) 323 static PassRefPtrWillBeRawPtr<MetadataRequest> create(PassRefPtr<RequestMeta dataCallback> requestCallback, const String& url)
325 { 324 {
(...skipping 13 matching lines...) Expand all
339 private: 338 private:
340 bool didHitError(FileError* error) 339 bool didHitError(FileError* error)
341 { 340 {
342 reportResult(error->code()); 341 reportResult(error->code());
343 return true; 342 return true;
344 } 343 }
345 344
346 bool didGetEntry(Entry*); 345 bool didGetEntry(Entry*);
347 bool didGetMetadata(Metadata*); 346 bool didGetMetadata(Metadata*);
348 347
349 void reportResult(FileError::ErrorCode errorCode, PassRefPtr<protocol::TypeB uilder::FileSystem::Metadata> metadata = nullptr) 348 void reportResult(FileError::ErrorCode errorCode, PassOwnPtr<protocol::TypeB uilder::FileSystem::Metadata> metadata = nullptr)
350 { 349 {
351 m_requestCallback->sendSuccess(static_cast<int>(errorCode), metadata); 350 m_requestCallback->sendSuccess(static_cast<int>(errorCode), metadata);
352 } 351 }
353 352
354 MetadataRequest(PassRefPtr<RequestMetadataCallback> requestCallback, const S tring& url) 353 MetadataRequest(PassRefPtr<RequestMetadataCallback> requestCallback, const S tring& url)
355 : m_requestCallback(requestCallback) 354 : m_requestCallback(requestCallback)
356 , m_url(ParsedURLString, url) { } 355 , m_url(ParsedURLString, url) { }
357 356
358 RefPtr<RequestMetadataCallback> m_requestCallback; 357 RefPtr<RequestMetadataCallback> m_requestCallback;
359 KURL m_url; 358 KURL m_url;
(...skipping 20 matching lines...) Expand all
380 MetadataCallback* successCallback = CallbackDispatcherFactory<MetadataCallba ck>::create(this, &MetadataRequest::didGetMetadata); 379 MetadataCallback* successCallback = CallbackDispatcherFactory<MetadataCallba ck>::create(this, &MetadataRequest::didGetMetadata);
381 ErrorCallback* errorCallback = CallbackDispatcherFactory<ErrorCallback>::cre ate(this, &MetadataRequest::didHitError); 380 ErrorCallback* errorCallback = CallbackDispatcherFactory<ErrorCallback>::cre ate(this, &MetadataRequest::didHitError);
382 entry->getMetadata(successCallback, errorCallback); 381 entry->getMetadata(successCallback, errorCallback);
383 m_isDirectory = entry->isDirectory(); 382 m_isDirectory = entry->isDirectory();
384 return true; 383 return true;
385 } 384 }
386 385
387 bool MetadataRequest::didGetMetadata(Metadata* metadata) 386 bool MetadataRequest::didGetMetadata(Metadata* metadata)
388 { 387 {
389 using protocol::TypeBuilder::FileSystem::Metadata; 388 using protocol::TypeBuilder::FileSystem::Metadata;
390 RefPtr<Metadata> result = Metadata::create() 389 OwnPtr<Metadata> result = Metadata::create()
391 .setModificationTime(metadata->modificationTime()) 390 .setModificationTime(metadata->modificationTime())
392 .setSize(metadata->size()); 391 .setSize(metadata->size()).build();
393 reportResult(static_cast<FileError::ErrorCode>(0), result); 392 reportResult(static_cast<FileError::ErrorCode>(0), result.release());
394 return true; 393 return true;
395 } 394 }
396 395
397 class FileContentRequest final : public EventListener { 396 class FileContentRequest final : public EventListener {
398 WTF_MAKE_NONCOPYABLE(FileContentRequest); 397 WTF_MAKE_NONCOPYABLE(FileContentRequest);
399 public: 398 public:
400 static PassRefPtrWillBeRawPtr<FileContentRequest> create(PassRefPtr<RequestF ileContentCallback> requestCallback, const String& url, bool readAsText, long lo ng start, long long end, const String& charset) 399 static PassRefPtrWillBeRawPtr<FileContentRequest> create(PassRefPtr<RequestF ileContentCallback> requestCallback, const String& url, bool readAsText, long lo ng start, long long end, const String& charset)
401 { 400 {
402 return adoptRefWillBeNoop(new FileContentRequest(requestCallback, url, r eadAsText, start, end, charset)); 401 return adoptRefWillBeNoop(new FileContentRequest(requestCallback, url, r eadAsText, start, end, charset));
403 } 402 }
(...skipping 29 matching lines...) Expand all
433 reportResult(error->code()); 432 reportResult(error->code());
434 return true; 433 return true;
435 } 434 }
436 435
437 bool didGetEntry(Entry*); 436 bool didGetEntry(Entry*);
438 bool didGetFile(Blob*); 437 bool didGetFile(Blob*);
439 void didRead(); 438 void didRead();
440 439
441 void reportResult(FileError::ErrorCode errorCode, const String* result = 0, const String* charset = 0) 440 void reportResult(FileError::ErrorCode errorCode, const String* result = 0, const String* charset = 0)
442 { 441 {
443 m_requestCallback->sendSuccess(static_cast<int>(errorCode), result, char set); 442 m_requestCallback->sendSuccess(static_cast<int>(errorCode), TypeBuilder: :optional(result), TypeBuilder::optional(charset));
444 } 443 }
445 444
446 FileContentRequest(PassRefPtr<RequestFileContentCallback> requestCallback, c onst String& url, bool readAsText, long long start, long long end, const String& charset) 445 FileContentRequest(PassRefPtr<RequestFileContentCallback> requestCallback, c onst String& url, bool readAsText, long long start, long long end, const String& charset)
447 : EventListener(EventListener::CPPEventListenerType) 446 : EventListener(EventListener::CPPEventListenerType)
448 , m_requestCallback(requestCallback) 447 , m_requestCallback(requestCallback)
449 , m_url(ParsedURLString, url) 448 , m_url(ParsedURLString, url)
450 , m_readAsText(readAsText) 449 , m_readAsText(readAsText)
451 , m_start(start) 450 , m_start(start)
452 , m_end(end) 451 , m_end(end)
453 , m_charset(charset) { } 452 , m_charset(charset) { }
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 void InspectorFileSystemAgent::disable(ErrorString*) 653 void InspectorFileSystemAgent::disable(ErrorString*)
655 { 654 {
656 if (!m_enabled) 655 if (!m_enabled)
657 return; 656 return;
658 m_enabled = false; 657 m_enabled = false;
659 m_state->setBoolean(FileSystemAgentState::fileSystemAgentEnabled, m_enabled) ; 658 m_state->setBoolean(FileSystemAgentState::fileSystemAgentEnabled, m_enabled) ;
660 } 659 }
661 660
662 void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const S tring& origin, const String& type, PassRefPtr<RequestFileSystemRootCallback> req uestCallback) 661 void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const S tring& origin, const String& type, PassRefPtr<RequestFileSystemRootCallback> req uestCallback)
663 { 662 {
664 if (!assertEnabled(error)) 663 if (!assertEnabled(error)) {
664 requestCallback->sendFailure(*error);
665 return; 665 return;
666 }
666 667
667 ExecutionContext* executionContext = assertExecutionContextForOrigin(error, SecurityOrigin::createFromString(origin).get()); 668 ExecutionContext* executionContext = assertExecutionContextForOrigin(error, SecurityOrigin::createFromString(origin).get());
668 if (!executionContext) 669 if (!executionContext) {
670 requestCallback->sendFailure(*error);
669 return; 671 return;
672 }
670 673
671 FileSystemRootRequest::create(requestCallback, type)->start(executionContext ); 674 FileSystemRootRequest::create(requestCallback, type)->start(executionContext );
672 } 675 }
673 676
674 void InspectorFileSystemAgent::requestDirectoryContent(ErrorString* error, const String& url, PassRefPtr<RequestDirectoryContentCallback> requestCallback) 677 void InspectorFileSystemAgent::requestDirectoryContent(ErrorString* error, const String& url, PassRefPtr<RequestDirectoryContentCallback> requestCallback)
675 { 678 {
676 if (!assertEnabled(error)) 679 if (!assertEnabled(error)) {
680 requestCallback->sendFailure(*error);
677 return; 681 return;
682 }
678 683
679 ExecutionContext* executionContext = assertExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get()); 684 ExecutionContext* executionContext = assertExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get());
680 if (!executionContext) 685 if (!executionContext) {
686 requestCallback->sendFailure(*error);
681 return; 687 return;
688 }
682 689
683 DirectoryContentRequest::create(requestCallback, url)->start(executionContex t); 690 DirectoryContentRequest::create(requestCallback, url)->start(executionContex t);
684 } 691 }
685 692
686 void InspectorFileSystemAgent::requestMetadata(ErrorString* error, const String& url, PassRefPtr<RequestMetadataCallback> requestCallback) 693 void InspectorFileSystemAgent::requestMetadata(ErrorString* error, const String& url, PassRefPtr<RequestMetadataCallback> requestCallback)
687 { 694 {
688 if (!assertEnabled(error)) 695 if (!assertEnabled(error)) {
696 requestCallback->sendFailure(*error);
689 return; 697 return;
698 }
690 699
691 ExecutionContext* executionContext = assertExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get()); 700 ExecutionContext* executionContext = assertExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get());
692 if (!executionContext) 701 if (!executionContext) {
702 requestCallback->sendFailure(*error);
693 return; 703 return;
704 }
694 705
695 MetadataRequest::create(requestCallback, url)->start(executionContext); 706 MetadataRequest::create(requestCallback, url)->start(executionContext);
696 } 707 }
697 708
698 void InspectorFileSystemAgent::requestFileContent(ErrorString* error, const Stri ng& url, bool readAsText, const int* start, const int* end, const String* charse t, PassRefPtr<RequestFileContentCallback> requestCallback) 709 void InspectorFileSystemAgent::requestFileContent(ErrorString* error, const Stri ng& url, bool readAsText, const OptionalValue<int>& start, const OptionalValue<i nt>& end, const OptionalValue<String>& charset, PassRefPtr<RequestFileContentCal lback> requestCallback)
699 { 710 {
700 if (!assertEnabled(error)) 711 if (!assertEnabled(error)) {
712 requestCallback->sendFailure(*error);
701 return; 713 return;
714 }
702 715
703 ExecutionContext* executionContext = assertExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get()); 716 ExecutionContext* executionContext = assertExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get());
704 if (!executionContext) 717 if (!executionContext) {
718 requestCallback->sendFailure(*error);
705 return; 719 return;
720 }
706 721
707 long long startPosition = start ? *start : 0; 722 int startPosition = start.get(0);
708 long long endPosition = end ? *end : std::numeric_limits<long long>::max(); 723 int endPosition = end.get(std::numeric_limits<int>::max());
709 FileContentRequest::create(requestCallback, url, readAsText, startPosition, endPosition, charset ? *charset : "")->start(executionContext); 724 FileContentRequest::create(requestCallback, url, readAsText, startPosition, endPosition, charset.get(""))->start(executionContext);
710 } 725 }
711 726
712 void InspectorFileSystemAgent::deleteEntry(ErrorString* error, const String& url String, PassRefPtr<DeleteEntryCallback> requestCallback) 727 void InspectorFileSystemAgent::deleteEntry(ErrorString* error, const String& url String, PassRefPtr<DeleteEntryCallback> requestCallback)
713 { 728 {
714 if (!assertEnabled(error)) 729 if (!assertEnabled(error)) {
730 requestCallback->sendFailure(*error);
715 return; 731 return;
732 }
716 733
717 KURL url(ParsedURLString, urlString); 734 KURL url(ParsedURLString, urlString);
718 735
719 ExecutionContext* executionContext = assertExecutionContextForOrigin(error, SecurityOrigin::create(url).get()); 736 ExecutionContext* executionContext = assertExecutionContextForOrigin(error, SecurityOrigin::create(url).get());
720 if (!executionContext) 737 if (!executionContext) {
738 requestCallback->sendFailure(*error);
721 return; 739 return;
740 }
722 741
723 DeleteEntryRequest::create(requestCallback, url)->start(executionContext); 742 DeleteEntryRequest::create(requestCallback, url)->start(executionContext);
724 } 743 }
725 744
726 void InspectorFileSystemAgent::restore() 745 void InspectorFileSystemAgent::restore()
727 { 746 {
728 m_enabled = m_state->booleanProperty(FileSystemAgentState::fileSystemAgentEn abled, false); 747 m_enabled = m_state->booleanProperty(FileSystemAgentState::fileSystemAgentEn abled, false);
729 } 748 }
730 749
731 InspectorFileSystemAgent::InspectorFileSystemAgent(InspectedFrames* inspectedFra mes) 750 InspectorFileSystemAgent::InspectorFileSystemAgent(InspectedFrames* inspectedFra mes)
(...skipping 24 matching lines...) Expand all
756 return 0; 775 return 0;
757 } 776 }
758 777
759 DEFINE_TRACE(InspectorFileSystemAgent) 778 DEFINE_TRACE(InspectorFileSystemAgent)
760 { 779 {
761 visitor->trace(m_inspectedFrames); 780 visitor->trace(m_inspectedFrames);
762 InspectorBaseAgent::trace(visitor); 781 InspectorBaseAgent::trace(visitor);
763 } 782 }
764 783
765 } // namespace blink 784 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698