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

Side by Side Diff: content/browser/dom_storage/dom_storage_context_wrapper.cc

Issue 2604273002: Migrate data from old localstorage format to new format. (Closed)
Patch Set: nit 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 | « no previous file | content/browser/dom_storage/local_storage_context_mojo.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/dom_storage/dom_storage_context_wrapper.h" 5 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 base::Owned(infos))); 76 base::Owned(infos)));
77 } 77 }
78 78
79 } // namespace 79 } // namespace
80 80
81 DOMStorageContextWrapper::DOMStorageContextWrapper( 81 DOMStorageContextWrapper::DOMStorageContextWrapper(
82 service_manager::Connector* connector, 82 service_manager::Connector* connector,
83 const base::FilePath& profile_path, 83 const base::FilePath& profile_path,
84 const base::FilePath& local_partition_path, 84 const base::FilePath& local_partition_path,
85 storage::SpecialStoragePolicy* special_storage_policy) { 85 storage::SpecialStoragePolicy* special_storage_policy) {
86 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
87 switches::kMojoLocalStorage)) {
88 base::FilePath storage_dir;
89 if (!profile_path.empty())
90 storage_dir = local_partition_path.AppendASCII(kLocalStorageDirectory);
91 // TODO(michaeln): Enable writing to disk when db is versioned,
92 // for now using an empty subdirectory to use an in-memory db.
93 // subdirectory_(subdirectory),
94 mojo_state_.reset(new LocalStorageContextMojo(
95 connector, base::FilePath() /* storage_dir */));
96 }
97
98 base::FilePath data_path; 86 base::FilePath data_path;
99 if (!profile_path.empty()) 87 if (!profile_path.empty())
100 data_path = profile_path.Append(local_partition_path); 88 data_path = profile_path.Append(local_partition_path);
101 89
102 scoped_refptr<base::SequencedTaskRunner> primary_sequence; 90 scoped_refptr<base::SequencedTaskRunner> primary_sequence;
103 scoped_refptr<base::SequencedTaskRunner> commit_sequence; 91 scoped_refptr<base::SequencedTaskRunner> commit_sequence;
104 if (GetContentClient()->browser()->ShouldRedirectDOMStorageTaskRunner()) { 92 if (GetContentClient()->browser()->ShouldRedirectDOMStorageTaskRunner()) {
105 // TaskPriority::USER_BLOCKING as an experiment because this is currently 93 // TaskPriority::USER_BLOCKING as an experiment because this is currently
106 // believed to be blocking synchronous IPCs from the renderers: 94 // believed to be blocking synchronous IPCs from the renderers:
107 // http://crbug.com/665588 (yes we want to fix that bug, but are taking it 95 // http://crbug.com/665588 (yes we want to fix that bug, but are taking it
(...skipping 19 matching lines...) Expand all
127 115
128 context_ = new DOMStorageContextImpl( 116 context_ = new DOMStorageContextImpl(
129 data_path.empty() ? data_path 117 data_path.empty() ? data_path
130 : data_path.AppendASCII(kLocalStorageDirectory), 118 : data_path.AppendASCII(kLocalStorageDirectory),
131 data_path.empty() ? data_path 119 data_path.empty() ? data_path
132 : data_path.AppendASCII(kSessionStorageDirectory), 120 : data_path.AppendASCII(kSessionStorageDirectory),
133 special_storage_policy, 121 special_storage_policy,
134 new DOMStorageWorkerPoolTaskRunner(std::move(primary_sequence), 122 new DOMStorageWorkerPoolTaskRunner(std::move(primary_sequence),
135 std::move(commit_sequence))); 123 std::move(commit_sequence)));
136 124
125 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
126 switches::kMojoLocalStorage)) {
127 base::FilePath storage_dir;
128 if (!profile_path.empty())
129 storage_dir = local_partition_path.AppendASCII(kLocalStorageDirectory);
130 // TODO(michaeln): Enable writing to disk when db is versioned,
131 // for now using an empty subdirectory to use an in-memory db.
132 // subdirectory_(subdirectory),
133 mojo_state_.reset(new LocalStorageContextMojo(
134 connector, context_->task_runner(),
135 data_path.empty() ? data_path
136 : data_path.AppendASCII(kLocalStorageDirectory),
137 base::FilePath() /* storage_dir */));
138 }
139
137 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { 140 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
138 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); 141 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this);
139 } else { 142 } else {
140 memory_pressure_listener_.reset(new base::MemoryPressureListener( 143 memory_pressure_listener_.reset(new base::MemoryPressureListener(
141 base::Bind(&DOMStorageContextWrapper::OnMemoryPressure, this))); 144 base::Bind(&DOMStorageContextWrapper::OnMemoryPressure, this)));
142 } 145 }
143 } 146 }
144 147
145 DOMStorageContextWrapper::~DOMStorageContextWrapper() {} 148 DOMStorageContextWrapper::~DOMStorageContextWrapper() {}
146 149
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 GetLocalStorageUsageCallback callback, 308 GetLocalStorageUsageCallback callback,
306 std::vector<LocalStorageUsageInfo> usage) { 309 std::vector<LocalStorageUsageInfo> usage) {
307 context_->task_runner()->PostShutdownBlockingTask( 310 context_->task_runner()->PostShutdownBlockingTask(
308 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, 311 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE,
309 base::Bind(&GetLocalStorageUsageHelper, base::Passed(&usage), 312 base::Bind(&GetLocalStorageUsageHelper, base::Passed(&usage),
310 base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), 313 base::RetainedRef(base::ThreadTaskRunnerHandle::Get()),
311 base::RetainedRef(context_), callback)); 314 base::RetainedRef(context_), callback));
312 } 315 }
313 316
314 } // namespace content 317 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/dom_storage/local_storage_context_mojo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698