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

Side by Side Diff: third_party/WebKit/Source/modules/quota/DeprecatedStorageQuota.cpp

Issue 2700753002: Replace ExecutionContextTask with WTF::Closure in StorageErrorCallback (Closed)
Patch Set: Created 3 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 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 21 matching lines...) Expand all
32 32
33 #include "bindings/core/v8/ScriptState.h" 33 #include "bindings/core/v8/ScriptState.h"
34 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
35 #include "core/dom/ExecutionContext.h" 35 #include "core/dom/ExecutionContext.h"
36 #include "core/dom/TaskRunnerHelper.h" 36 #include "core/dom/TaskRunnerHelper.h"
37 #include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h" 37 #include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h"
38 #include "modules/quota/StorageErrorCallback.h" 38 #include "modules/quota/StorageErrorCallback.h"
39 #include "modules/quota/StorageQuotaClient.h" 39 #include "modules/quota/StorageQuotaClient.h"
40 #include "modules/quota/StorageUsageCallback.h" 40 #include "modules/quota/StorageUsageCallback.h"
41 #include "platform/StorageQuotaCallbacks.h" 41 #include "platform/StorageQuotaCallbacks.h"
42 #include "platform/WebTaskRunner.h"
42 #include "platform/weborigin/KURL.h" 43 #include "platform/weborigin/KURL.h"
43 #include "platform/weborigin/SecurityOrigin.h" 44 #include "platform/weborigin/SecurityOrigin.h"
44 #include "public/platform/Platform.h" 45 #include "public/platform/Platform.h"
45 #include "public/platform/WebStorageQuotaCallbacks.h" 46 #include "public/platform/WebStorageQuotaCallbacks.h"
46 #include "public/platform/WebStorageQuotaType.h" 47 #include "public/platform/WebStorageQuotaType.h"
47 #include "public/platform/WebTraceLocation.h" 48 #include "public/platform/WebTraceLocation.h"
48 49
49 namespace blink { 50 namespace blink {
50 51
51 DeprecatedStorageQuota::DeprecatedStorageQuota(Type type) : m_type(type) {} 52 DeprecatedStorageQuota::DeprecatedStorageQuota(Type type) : m_type(type) {}
52 53
53 void DeprecatedStorageQuota::queryUsageAndQuota( 54 void DeprecatedStorageQuota::queryUsageAndQuota(
54 ScriptState* scriptState, 55 ScriptState* scriptState,
55 StorageUsageCallback* successCallback, 56 StorageUsageCallback* successCallback,
56 StorageErrorCallback* errorCallback) { 57 StorageErrorCallback* errorCallback) {
57 ExecutionContext* executionContext = scriptState->getExecutionContext(); 58 ExecutionContext* executionContext = scriptState->getExecutionContext();
58 ASSERT(executionContext); 59 ASSERT(executionContext);
59 60
60 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); 61 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type);
61 if (storageType != WebStorageQuotaTypeTemporary && 62 if (storageType != WebStorageQuotaTypeTemporary &&
62 storageType != WebStorageQuotaTypePersistent) { 63 storageType != WebStorageQuotaTypePersistent) {
63 // Unknown storage type is requested. 64 // Unknown storage type is requested.
64 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE, 65 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext)
65 StorageErrorCallback::createSameThreadTask( 66 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask(
66 errorCallback, NotSupportedError)); 67 errorCallback, NotSupportedError));
67 return; 68 return;
68 } 69 }
69 70
70 SecurityOrigin* securityOrigin = executionContext->getSecurityOrigin(); 71 SecurityOrigin* securityOrigin = executionContext->getSecurityOrigin();
71 if (securityOrigin->isUnique()) { 72 if (securityOrigin->isUnique()) {
72 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE, 73 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext)
73 StorageErrorCallback::createSameThreadTask( 74 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask(
74 errorCallback, NotSupportedError)); 75 errorCallback, NotSupportedError));
75 return; 76 return;
76 } 77 }
77 78
78 KURL storagePartition = KURL(KURL(), securityOrigin->toString()); 79 KURL storagePartition = KURL(KURL(), securityOrigin->toString());
79 StorageQuotaCallbacks* callbacks = 80 StorageQuotaCallbacks* callbacks =
80 DeprecatedStorageQuotaCallbacksImpl::create(successCallback, 81 DeprecatedStorageQuotaCallbacksImpl::create(successCallback,
81 errorCallback); 82 errorCallback);
82 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType, 83 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType,
83 callbacks); 84 callbacks);
84 } 85 }
85 86
86 void DeprecatedStorageQuota::requestQuota(ScriptState* scriptState, 87 void DeprecatedStorageQuota::requestQuota(ScriptState* scriptState,
87 unsigned long long newQuotaInBytes, 88 unsigned long long newQuotaInBytes,
88 StorageQuotaCallback* successCallback, 89 StorageQuotaCallback* successCallback,
89 StorageErrorCallback* errorCallback) { 90 StorageErrorCallback* errorCallback) {
90 ExecutionContext* executionContext = scriptState->getExecutionContext(); 91 ExecutionContext* executionContext = scriptState->getExecutionContext();
91 ASSERT(executionContext); 92 ASSERT(executionContext);
92 93
93 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); 94 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type);
94 if (storageType != WebStorageQuotaTypeTemporary && 95 if (storageType != WebStorageQuotaTypeTemporary &&
95 storageType != WebStorageQuotaTypePersistent) { 96 storageType != WebStorageQuotaTypePersistent) {
96 // Unknown storage type is requested. 97 // Unknown storage type is requested.
97 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE, 98 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext)
98 StorageErrorCallback::createSameThreadTask( 99 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask(
99 errorCallback, NotSupportedError)); 100 errorCallback, NotSupportedError));
100 return; 101 return;
101 } 102 }
102 103
103 StorageQuotaClient* client = StorageQuotaClient::from(executionContext); 104 StorageQuotaClient* client = StorageQuotaClient::from(executionContext);
104 if (!client) { 105 if (!client) {
105 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE, 106 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext)
106 StorageErrorCallback::createSameThreadTask( 107 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask(
107 errorCallback, NotSupportedError)); 108 errorCallback, NotSupportedError));
108 return; 109 return;
109 } 110 }
110 111
111 client->requestQuota(scriptState, storageType, newQuotaInBytes, 112 client->requestQuota(scriptState, storageType, newQuotaInBytes,
112 successCallback, errorCallback); 113 successCallback, errorCallback);
113 } 114 }
114 115
115 } // namespace blink 116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698