Changeset 255136 in webkit


Ignore:
Timestamp:
Jan 26, 2020 10:27:38 PM (4 years ago)
Author:
Darin Adler
Message:

Move DOMCacheEngine::errorToException back out of header and into .cpp file
https://bugs.webkit.org/show_bug.cgi?id=206815

Reviewed by Mark Lam.

This is a follow-up to a recent build fix that moved a function, errorToException,
out of a .cpp file and into a header file. This reverses that since we don't need
this function to be inlined.

  • Modules/cache/DOMCacheEngine.cpp:

(WebCore::DOMCacheEngine::convertToException): Moved this function from the header
and renamed it from errorToException to match the other function more closely. Also
use the pattern where the switch statement has no default, so we get a warning if
we don't cover all the enum values.
(WebCore::DOMCacheEngine::convertToExceptionAndLog): Updated for new function name.

  • Modules/cache/DOMCacheEngine.h: Removed the definition of errorToException and

replaced it with the declaration of it under its new name, convertToException.

  • Modules/cache/DOMCacheStorage.cpp:

(WebCore::DOMCacheStorage::retrieveCaches): Updated for new function name.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r255133 r255136  
     12020-01-26  Darin Adler  <darin@apple.com>
     2
     3        Move DOMCacheEngine::errorToException back out of header and into .cpp file
     4        https://bugs.webkit.org/show_bug.cgi?id=206815
     5
     6        Reviewed by Mark Lam.
     7
     8        This is a follow-up to a recent build fix that moved a function, errorToException,
     9        out of a .cpp file and into a header file. This reverses that since we don't need
     10        this function to be inlined.
     11
     12        * Modules/cache/DOMCacheEngine.cpp:
     13        (WebCore::DOMCacheEngine::convertToException): Moved this function from the header
     14        and renamed it from errorToException to match the other function more closely. Also
     15        use the pattern where the switch statement has no default, so we get a warning if
     16        we don't cover all the enum values.
     17        (WebCore::DOMCacheEngine::convertToExceptionAndLog): Updated for new function name.
     18
     19        * Modules/cache/DOMCacheEngine.h: Removed the definition of errorToException and
     20        replaced it with the declaration of it under its new name, convertToException.
     21
     22        * Modules/cache/DOMCacheStorage.cpp:
     23        (WebCore::DOMCacheStorage::retrieveCaches): Updated for new function name.
     24
    1252020-01-26  youenn fablet  <youenn@apple.com>
    226
  • trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp

    r255070 r255136  
    3636namespace DOMCacheEngine {
    3737
     38Exception convertToException(Error error)
     39{
     40    switch (error) {
     41    case Error::NotImplemented:
     42        return Exception { NotSupportedError, "Not implemented"_s };
     43    case Error::ReadDisk:
     44        return Exception { TypeError, "Failed reading data from the file system"_s };
     45    case Error::WriteDisk:
     46        return Exception { TypeError, "Failed writing data to the file system"_s };
     47    case Error::QuotaExceeded:
     48        return Exception { QuotaExceededError, "Quota exceeded"_s };
     49    case Error::Internal:
     50        return Exception { TypeError, "Internal error"_s };
     51    case Error::Stopped:
     52        return Exception { TypeError, "Context is stopped"_s };
     53    }
     54    ASSERT_NOT_REACHED();
     55    return Exception { TypeError, "Connection stopped"_s };
     56}
     57
    3858Exception convertToExceptionAndLog(ScriptExecutionContext* context, Error error)
    3959{
    40     auto exception = errorToException(error);
     60    auto exception = convertToException(error);
    4161    if (context)
    4262        context->addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Cache API operation failed: ", exception.message()));
  • trunk/Source/WebCore/Modules/cache/DOMCacheEngine.h

    r255070 r255136  
    3131#include "ResourceRequest.h"
    3232#include "ResourceResponse.h"
    33 #include "ScriptExecutionContext.h"
    3433#include "SharedBuffer.h"
    3534#include <wtf/CompletionHandler.h>
    3635
    3736namespace WebCore {
     37
     38class ScriptExecutionContext;
    3839
    3940struct CacheQueryOptions;
     
    5051};
    5152
    52 static inline Exception errorToException(Error error)
    53 {
    54     switch (error) {
    55     case Error::NotImplemented:
    56         return Exception { NotSupportedError, "Not implemented"_s };
    57     case Error::ReadDisk:
    58         return Exception { TypeError, "Failed reading data from the file system"_s };
    59     case Error::WriteDisk:
    60         return Exception { TypeError, "Failed writing data to the file system"_s };
    61     case Error::QuotaExceeded:
    62         return Exception { QuotaExceededError, "Quota exceeded"_s };
    63     case Error::Internal:
    64         return Exception { TypeError, "Internal error"_s };
    65     case Error::Stopped:
    66         return Exception { TypeError, "Context is stopped"_s };
    67     default:
    68         ASSERT_NOT_REACHED();
    69         return Exception { TypeError, "Connection stopped"_s };
    70     }
    71 }
    72 
     53Exception convertToException(Error);
    7354Exception convertToExceptionAndLog(ScriptExecutionContext*, Error);
    7455
  • trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp

    r255070 r255136  
    152152    m_connection->retrieveCaches(*origin, m_updateCounter, [this, callback = WTFMove(callback), pendingActivity = makePendingActivity(*this)](CacheInfosOrError&& result) mutable {
    153153        if (m_isStopped) {
    154             callback(DOMCacheEngine::errorToException(DOMCacheEngine::Error::Stopped));
     154            callback(DOMCacheEngine::convertToException(DOMCacheEngine::Error::Stopped));
    155155            return;
    156156        }
Note: See TracChangeset for help on using the changeset viewer.