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

Side by Side Diff: content/browser/devtools/protocol/storage_handler.cc

Issue 2576643003: Revert of [DevTools] Migrate storage domain to new generator. (Closed)
Patch Set: Created 4 years 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/devtools/protocol/storage_handler.h" 5 #include "content/browser/devtools/protocol/storage_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <unordered_set> 8 #include <unordered_set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "content/browser/frame_host/render_frame_host_impl.h" 12 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h"
13 #include "content/public/browser/render_frame_host.h"
13 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/storage_partition.h" 15 #include "content/public/browser/storage_partition.h"
15 16
16 namespace content { 17 namespace content {
17 namespace protocol { 18 namespace devtools {
19 namespace storage {
18 20
19 namespace { 21 namespace {
20 static const char kAppCache[] = "appcache"; 22 static const char kAppCache[] = "appcache";
21 static const char kCookies[] = "cookies"; 23 static const char kCookies[] = "cookies";
22 static const char kFileSystems[] = "filesystems"; 24 static const char kFileSystems[] = "filesystems";
23 static const char kIndexedDB[] = "indexeddb"; 25 static const char kIndexedDB[] = "indexeddb";
24 static const char kLocalStorage[] = "local_storage"; 26 static const char kLocalStorage[] = "local_storage";
25 static const char kShaderCache[] = "shader_cache"; 27 static const char kShaderCache[] = "shader_cache";
26 static const char kWebSQL[] = "websql"; 28 static const char kWebSQL[] = "websql";
27 static const char kServiceWorkers[] = "service_workers"; 29 static const char kServiceWorkers[] = "service_workers";
28 static const char kCacheStorage[] = "cache_storage"; 30 static const char kCacheStorage[] = "cache_storage";
29 static const char kAll[] = "all"; 31 static const char kAll[] = "all";
30 } 32 }
31 33
34 typedef DevToolsProtocolClient::Response Response;
35
32 StorageHandler::StorageHandler() 36 StorageHandler::StorageHandler()
33 : host_(nullptr) { 37 : host_(nullptr) {
34 } 38 }
35 39
36 StorageHandler::~StorageHandler() = default; 40 StorageHandler::~StorageHandler() = default;
37 41
38 void StorageHandler::Wire(UberDispatcher* dispatcher) { 42 void StorageHandler::SetRenderFrameHost(RenderFrameHost* host) {
39 Storage::Dispatcher::wire(dispatcher, this);
40 }
41
42 void StorageHandler::SetRenderFrameHost(RenderFrameHostImpl* host) {
43 host_ = host; 43 host_ = host;
44 } 44 }
45 45
46 Response StorageHandler::Disable() {
47 return Response::OK();
48 }
49
50 Response StorageHandler::ClearDataForOrigin( 46 Response StorageHandler::ClearDataForOrigin(
51 const std::string& origin, 47 const std::string& origin,
52 const std::string& storage_types) { 48 const std::string& storage_types) {
53 if (!host_) 49 if (!host_)
54 return Response::InternalError(); 50 return Response::InternalError("Not connected to host");
55 51
56 StoragePartition* partition = host_->GetProcess()->GetStoragePartition(); 52 StoragePartition* partition = host_->GetProcess()->GetStoragePartition();
57 std::vector<std::string> types = base::SplitString( 53 std::vector<std::string> types = base::SplitString(
58 storage_types, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 54 storage_types, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
59 std::unordered_set<std::string> set(types.begin(), types.end()); 55 std::unordered_set<std::string> set(types.begin(), types.end());
60 uint32_t remove_mask = 0; 56 uint32_t remove_mask = 0;
61 if (set.count(kAppCache)) 57 if (set.count(kAppCache))
62 remove_mask |= StoragePartition::REMOVE_DATA_MASK_APPCACHE; 58 remove_mask |= StoragePartition::REMOVE_DATA_MASK_APPCACHE;
63 if (set.count(kCookies)) 59 if (set.count(kCookies))
64 remove_mask |= StoragePartition::REMOVE_DATA_MASK_COOKIES; 60 remove_mask |= StoragePartition::REMOVE_DATA_MASK_COOKIES;
(...skipping 19 matching lines...) Expand all
84 80
85 partition->ClearDataForOrigin( 81 partition->ClearDataForOrigin(
86 remove_mask, 82 remove_mask,
87 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, 83 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
88 GURL(origin), 84 GURL(origin),
89 partition->GetURLRequestContext(), 85 partition->GetURLRequestContext(),
90 base::Bind(&base::DoNothing)); 86 base::Bind(&base::DoNothing));
91 return Response::OK(); 87 return Response::OK();
92 } 88 }
93 89
94 } // namespace protocol 90 } // namespace storage
91 } // namespace devtools
95 } // namespace content 92 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/storage_handler.h ('k') | content/browser/devtools/protocol_config.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698