OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 namespace blink { | 75 namespace blink { |
76 | 76 |
77 namespace FileSystemAgentState { | 77 namespace FileSystemAgentState { |
78 static const char fileSystemAgentEnabled[] = "fileSystemAgentEnabled"; | 78 static const char fileSystemAgentEnabled[] = "fileSystemAgentEnabled"; |
79 } | 79 } |
80 | 80 |
81 namespace { | 81 namespace { |
82 | 82 |
83 template<typename BaseCallback, typename Handler, typename Argument> | 83 template<typename BaseCallback, typename Handler, typename Argument> |
84 class CallbackDispatcher FINAL : public BaseCallback { | 84 class CallbackDispatcher final : public BaseCallback { |
85 public: | 85 public: |
86 typedef bool (Handler::*HandlingMethod)(Argument); | 86 typedef bool (Handler::*HandlingMethod)(Argument); |
87 | 87 |
88 static CallbackDispatcher* create(PassRefPtr<Handler> handler, HandlingMetho
d handlingMethod) | 88 static CallbackDispatcher* create(PassRefPtr<Handler> handler, HandlingMetho
d handlingMethod) |
89 { | 89 { |
90 return new CallbackDispatcher(handler, handlingMethod); | 90 return new CallbackDispatcher(handler, handlingMethod); |
91 } | 91 } |
92 | 92 |
93 virtual void handleEvent(Argument argument) OVERRIDE | 93 virtual void handleEvent(Argument argument) override |
94 { | 94 { |
95 (m_handler.get()->*m_handlingMethod)(argument); | 95 (m_handler.get()->*m_handlingMethod)(argument); |
96 } | 96 } |
97 | 97 |
98 private: | 98 private: |
99 CallbackDispatcher(PassRefPtr<Handler> handler, HandlingMethod handlingMetho
d) | 99 CallbackDispatcher(PassRefPtr<Handler> handler, HandlingMethod handlingMetho
d) |
100 : m_handler(handler) | 100 : m_handler(handler) |
101 , m_handlingMethod(handlingMethod) { } | 101 , m_handlingMethod(handlingMethod) { } |
102 | 102 |
103 RefPtr<Handler> m_handler; | 103 RefPtr<Handler> m_handler; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 bool FileSystemRootRequest::didGetEntry(Entry* entry) | 172 bool FileSystemRootRequest::didGetEntry(Entry* entry) |
173 { | 173 { |
174 RefPtr<TypeBuilder::FileSystem::Entry> result = TypeBuilder::FileSystem::Ent
ry::create() | 174 RefPtr<TypeBuilder::FileSystem::Entry> result = TypeBuilder::FileSystem::Ent
ry::create() |
175 .setUrl(entry->toURL()) | 175 .setUrl(entry->toURL()) |
176 .setName("/") | 176 .setName("/") |
177 .setIsDirectory(true); | 177 .setIsDirectory(true); |
178 reportResult(static_cast<FileError::ErrorCode>(0), result); | 178 reportResult(static_cast<FileError::ErrorCode>(0), result); |
179 return true; | 179 return true; |
180 } | 180 } |
181 | 181 |
182 class DirectoryContentRequest FINAL : public RefCounted<DirectoryContentRequest>
{ | 182 class DirectoryContentRequest final : public RefCounted<DirectoryContentRequest>
{ |
183 WTF_MAKE_NONCOPYABLE(DirectoryContentRequest); | 183 WTF_MAKE_NONCOPYABLE(DirectoryContentRequest); |
184 public: | 184 public: |
185 static PassRefPtr<DirectoryContentRequest> create(PassRefPtrWillBeRawPtr<Req
uestDirectoryContentCallback> requestCallback, const String& url) | 185 static PassRefPtr<DirectoryContentRequest> create(PassRefPtrWillBeRawPtr<Req
uestDirectoryContentCallback> requestCallback, const String& url) |
186 { | 186 { |
187 return adoptRef(new DirectoryContentRequest(requestCallback, url)); | 187 return adoptRef(new DirectoryContentRequest(requestCallback, url)); |
188 } | 188 } |
189 | 189 |
190 ~DirectoryContentRequest() | 190 ~DirectoryContentRequest() |
191 { | 191 { |
192 reportResult(FileError::ABORT_ERR); | 192 reportResult(FileError::ABORT_ERR); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 entryForFrontend->setMimeType(mimeType); | 293 entryForFrontend->setMimeType(mimeType); |
294 entryForFrontend->setResourceType(resourceType); | 294 entryForFrontend->setResourceType(resourceType); |
295 } | 295 } |
296 | 296 |
297 m_entries->addItem(entryForFrontend); | 297 m_entries->addItem(entryForFrontend); |
298 } | 298 } |
299 readDirectoryEntries(); | 299 readDirectoryEntries(); |
300 return true; | 300 return true; |
301 } | 301 } |
302 | 302 |
303 class MetadataRequest FINAL : public RefCounted<MetadataRequest> { | 303 class MetadataRequest final : public RefCounted<MetadataRequest> { |
304 WTF_MAKE_NONCOPYABLE(MetadataRequest); | 304 WTF_MAKE_NONCOPYABLE(MetadataRequest); |
305 public: | 305 public: |
306 static PassRefPtr<MetadataRequest> create(PassRefPtrWillBeRawPtr<RequestMeta
dataCallback> requestCallback, const String& url) | 306 static PassRefPtr<MetadataRequest> create(PassRefPtrWillBeRawPtr<RequestMeta
dataCallback> requestCallback, const String& url) |
307 { | 307 { |
308 return adoptRef(new MetadataRequest(requestCallback, url)); | 308 return adoptRef(new MetadataRequest(requestCallback, url)); |
309 } | 309 } |
310 | 310 |
311 ~MetadataRequest() | 311 ~MetadataRequest() |
312 { | 312 { |
313 reportResult(FileError::ABORT_ERR); | 313 reportResult(FileError::ABORT_ERR); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 bool MetadataRequest::didGetMetadata(Metadata* metadata) | 366 bool MetadataRequest::didGetMetadata(Metadata* metadata) |
367 { | 367 { |
368 using TypeBuilder::FileSystem::Metadata; | 368 using TypeBuilder::FileSystem::Metadata; |
369 RefPtr<Metadata> result = Metadata::create() | 369 RefPtr<Metadata> result = Metadata::create() |
370 .setModificationTime(metadata->modificationTime()) | 370 .setModificationTime(metadata->modificationTime()) |
371 .setSize(metadata->size()); | 371 .setSize(metadata->size()); |
372 reportResult(static_cast<FileError::ErrorCode>(0), result); | 372 reportResult(static_cast<FileError::ErrorCode>(0), result); |
373 return true; | 373 return true; |
374 } | 374 } |
375 | 375 |
376 class FileContentRequest FINAL : public EventListener { | 376 class FileContentRequest final : public EventListener { |
377 WTF_MAKE_NONCOPYABLE(FileContentRequest); | 377 WTF_MAKE_NONCOPYABLE(FileContentRequest); |
378 public: | 378 public: |
379 static PassRefPtr<FileContentRequest> create(PassRefPtrWillBeRawPtr<RequestF
ileContentCallback> requestCallback, const String& url, bool readAsText, long lo
ng start, long long end, const String& charset) | 379 static PassRefPtr<FileContentRequest> create(PassRefPtrWillBeRawPtr<RequestF
ileContentCallback> requestCallback, const String& url, bool readAsText, long lo
ng start, long long end, const String& charset) |
380 { | 380 { |
381 return adoptRef(new FileContentRequest(requestCallback, url, readAsText,
start, end, charset)); | 381 return adoptRef(new FileContentRequest(requestCallback, url, readAsText,
start, end, charset)); |
382 } | 382 } |
383 | 383 |
384 virtual ~FileContentRequest() | 384 virtual ~FileContentRequest() |
385 { | 385 { |
386 reportResult(FileError::ABORT_ERR); | 386 reportResult(FileError::ABORT_ERR); |
387 } | 387 } |
388 | 388 |
389 void start(ExecutionContext*); | 389 void start(ExecutionContext*); |
390 | 390 |
391 virtual bool operator==(const EventListener& other) OVERRIDE | 391 virtual bool operator==(const EventListener& other) override |
392 { | 392 { |
393 return this == &other; | 393 return this == &other; |
394 } | 394 } |
395 | 395 |
396 virtual void handleEvent(ExecutionContext*, Event* event) OVERRIDE | 396 virtual void handleEvent(ExecutionContext*, Event* event) override |
397 { | 397 { |
398 if (event->type() == EventTypeNames::load) | 398 if (event->type() == EventTypeNames::load) |
399 didRead(); | 399 didRead(); |
400 else if (event->type() == EventTypeNames::error) | 400 else if (event->type() == EventTypeNames::error) |
401 didHitError(m_reader->error()); | 401 didHitError(m_reader->error()); |
402 } | 402 } |
403 | 403 |
404 private: | 404 private: |
405 bool didHitError(FileError* error) | 405 bool didHitError(FileError* error) |
406 { | 406 { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 return; | 490 return; |
491 } | 491 } |
492 | 492 |
493 OwnPtr<TextResourceDecoder> decoder = TextResourceDecoder::create(m_mimeType
, m_charset, true); | 493 OwnPtr<TextResourceDecoder> decoder = TextResourceDecoder::create(m_mimeType
, m_charset, true); |
494 String result = decoder->decode(static_cast<char*>(buffer->data()), buffer->
byteLength()); | 494 String result = decoder->decode(static_cast<char*>(buffer->data()), buffer->
byteLength()); |
495 result = result + decoder->flush(); | 495 result = result + decoder->flush(); |
496 m_charset = decoder->encoding().name(); | 496 m_charset = decoder->encoding().name(); |
497 reportResult(static_cast<FileError::ErrorCode>(0), &result, &m_charset); | 497 reportResult(static_cast<FileError::ErrorCode>(0), &result, &m_charset); |
498 } | 498 } |
499 | 499 |
500 class DeleteEntryRequest FINAL : public RefCounted<DeleteEntryRequest> { | 500 class DeleteEntryRequest final : public RefCounted<DeleteEntryRequest> { |
501 public: | 501 public: |
502 static PassRefPtr<DeleteEntryRequest> create(PassRefPtrWillBeRawPtr<DeleteEn
tryCallback> requestCallback, const KURL& url) | 502 static PassRefPtr<DeleteEntryRequest> create(PassRefPtrWillBeRawPtr<DeleteEn
tryCallback> requestCallback, const KURL& url) |
503 { | 503 { |
504 return adoptRef(new DeleteEntryRequest(requestCallback, url)); | 504 return adoptRef(new DeleteEntryRequest(requestCallback, url)); |
505 } | 505 } |
506 | 506 |
507 ~DeleteEntryRequest() | 507 ~DeleteEntryRequest() |
508 { | 508 { |
509 reportResult(FileError::ABORT_ERR); | 509 reportResult(FileError::ABORT_ERR); |
510 } | 510 } |
511 | 511 |
512 void start(ExecutionContext*); | 512 void start(ExecutionContext*); |
513 | 513 |
514 private: | 514 private: |
515 // CallbackDispatcherFactory doesn't handle 0-arg handleEvent methods | 515 // CallbackDispatcherFactory doesn't handle 0-arg handleEvent methods |
516 class VoidCallbackImpl FINAL : public VoidCallback { | 516 class VoidCallbackImpl final : public VoidCallback { |
517 public: | 517 public: |
518 explicit VoidCallbackImpl(PassRefPtr<DeleteEntryRequest> handler) | 518 explicit VoidCallbackImpl(PassRefPtr<DeleteEntryRequest> handler) |
519 : m_handler(handler) | 519 : m_handler(handler) |
520 { | 520 { |
521 } | 521 } |
522 | 522 |
523 virtual void handleEvent() OVERRIDE | 523 virtual void handleEvent() override |
524 { | 524 { |
525 m_handler->didDeleteEntry(); | 525 m_handler->didDeleteEntry(); |
526 } | 526 } |
527 | 527 |
528 private: | 528 private: |
529 RefPtr<DeleteEntryRequest> m_handler; | 529 RefPtr<DeleteEntryRequest> m_handler; |
530 }; | 530 }; |
531 | 531 |
532 bool didHitError(FileError* error) | 532 bool didHitError(FileError* error) |
533 { | 533 { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 return 0; | 728 return 0; |
729 } | 729 } |
730 | 730 |
731 void InspectorFileSystemAgent::trace(Visitor* visitor) | 731 void InspectorFileSystemAgent::trace(Visitor* visitor) |
732 { | 732 { |
733 visitor->trace(m_page); | 733 visitor->trace(m_page); |
734 InspectorBaseAgent::trace(visitor); | 734 InspectorBaseAgent::trace(visitor); |
735 } | 735 } |
736 | 736 |
737 } // namespace blink | 737 } // namespace blink |
OLD | NEW |