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

Side by Side Diff: third_party/WebKit/Source/web/StorageQuotaClientImpl.cpp

Issue 2583013002: Specify TaskType of posted Task explicitly in Quota API (13) (Closed)
Patch Set: rebase Created 3 years, 11 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/modules/quota/DeprecatedStorageQuota.cpp ('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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "web/StorageQuotaClientImpl.h" 31 #include "web/StorageQuotaClientImpl.h"
32 32
33 #include "bindings/core/v8/ScriptPromise.h" 33 #include "bindings/core/v8/ScriptPromise.h"
34 #include "bindings/core/v8/ScriptPromiseResolver.h" 34 #include "bindings/core/v8/ScriptPromiseResolver.h"
35 #include "bindings/core/v8/ScriptState.h" 35 #include "bindings/core/v8/ScriptState.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/dom/ExceptionCode.h" 37 #include "core/dom/ExceptionCode.h"
38 #include "core/dom/ExecutionContext.h" 38 #include "core/dom/ExecutionContext.h"
39 #include "core/dom/TaskRunnerHelper.h"
39 #include "modules/quota/DOMError.h" 40 #include "modules/quota/DOMError.h"
40 #include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h" 41 #include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h"
41 #include "modules/quota/StorageErrorCallback.h" 42 #include "modules/quota/StorageErrorCallback.h"
42 #include "modules/quota/StorageQuotaCallback.h" 43 #include "modules/quota/StorageQuotaCallback.h"
43 #include "modules/quota/StorageQuotaCallbacksImpl.h" 44 #include "modules/quota/StorageQuotaCallbacksImpl.h"
44 #include "modules/quota/StorageUsageCallback.h" 45 #include "modules/quota/StorageUsageCallback.h"
45 #include "public/platform/WebStorageQuotaType.h" 46 #include "public/platform/WebStorageQuotaType.h"
46 #include "public/web/WebFrameClient.h" 47 #include "public/web/WebFrameClient.h"
47 #include "web/WebLocalFrameImpl.h" 48 #include "web/WebLocalFrameImpl.h"
48 #include "wtf/Threading.h" 49 #include "wtf/Threading.h"
(...skipping 15 matching lines...) Expand all
64 Document* document = toDocument(executionContext); 65 Document* document = toDocument(executionContext);
65 WebLocalFrameImpl* webFrame = 66 WebLocalFrameImpl* webFrame =
66 WebLocalFrameImpl::fromFrame(document->frame()); 67 WebLocalFrameImpl::fromFrame(document->frame());
67 StorageQuotaCallbacks* callbacks = 68 StorageQuotaCallbacks* callbacks =
68 DeprecatedStorageQuotaCallbacksImpl::create(successCallback, 69 DeprecatedStorageQuotaCallbacksImpl::create(successCallback,
69 errorCallback); 70 errorCallback);
70 webFrame->client()->requestStorageQuota(storageType, newQuotaInBytes, 71 webFrame->client()->requestStorageQuota(storageType, newQuotaInBytes,
71 callbacks); 72 callbacks);
72 } else { 73 } else {
73 // Requesting quota in Worker is not supported. 74 // Requesting quota in Worker is not supported.
74 executionContext->postTask(BLINK_FROM_HERE, 75 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE,
75 StorageErrorCallback::createSameThreadTask( 76 StorageErrorCallback::createSameThreadTask(
76 errorCallback, NotSupportedError)); 77 errorCallback, NotSupportedError));
77 } 78 }
78 } 79 }
79 80
80 ScriptPromise StorageQuotaClientImpl::requestPersistentQuota( 81 ScriptPromise StorageQuotaClientImpl::requestPersistentQuota(
81 ScriptState* scriptState, 82 ScriptState* scriptState,
82 unsigned long long newQuotaInBytes) { 83 unsigned long long newQuotaInBytes) {
83 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 84 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
84 ScriptPromise promise = resolver->promise(); 85 ScriptPromise promise = resolver->promise();
85 86
86 if (scriptState->getExecutionContext()->isDocument()) { 87 if (scriptState->getExecutionContext()->isDocument()) {
87 Document* document = toDocument(scriptState->getExecutionContext()); 88 Document* document = toDocument(scriptState->getExecutionContext());
88 WebLocalFrameImpl* webFrame = 89 WebLocalFrameImpl* webFrame =
89 WebLocalFrameImpl::fromFrame(document->frame()); 90 WebLocalFrameImpl::fromFrame(document->frame());
90 StorageQuotaCallbacks* callbacks = 91 StorageQuotaCallbacks* callbacks =
91 StorageQuotaCallbacksImpl::create(resolver); 92 StorageQuotaCallbacksImpl::create(resolver);
92 webFrame->client()->requestStorageQuota(WebStorageQuotaTypePersistent, 93 webFrame->client()->requestStorageQuota(WebStorageQuotaTypePersistent,
93 newQuotaInBytes, callbacks); 94 newQuotaInBytes, callbacks);
94 } else { 95 } else {
95 // Requesting quota in Worker is not supported. 96 // Requesting quota in Worker is not supported.
96 resolver->reject(DOMError::create(NotSupportedError)); 97 resolver->reject(DOMError::create(NotSupportedError));
97 } 98 }
98 99
99 return promise; 100 return promise;
100 } 101 }
101 102
102 } // namespace blink 103 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/quota/DeprecatedStorageQuota.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698