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

Side by Side Diff: chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc

Issue 159778: Make LocalStorage persistent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h" 5 #include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "chrome/browser/chrome_thread.h" 9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/in_process_webkit/webkit_context.h" 10 #include "chrome/browser/in_process_webkit/webkit_context.h"
11 #include "chrome/browser/in_process_webkit/webkit_thread.h" 11 #include "chrome/browser/in_process_webkit/webkit_thread.h"
12 #include "chrome/common/render_messages.h" 12 #include "chrome/common/render_messages.h"
13 #include "webkit/api/public/WebKit.h" 13 #include "webkit/api/public/WebKit.h"
14 #include "webkit/api/public/WebStorageArea.h" 14 #include "webkit/api/public/WebStorageArea.h"
15 #include "webkit/api/public/WebStorageNamespace.h" 15 #include "webkit/api/public/WebStorageNamespace.h"
16 #include "webkit/api/public/WebString.h" 16 #include "webkit/api/public/WebString.h"
17 #include "webkit/glue/webkit_glue.h"
17 18
18 using WebKit::WebStorageArea; 19 using WebKit::WebStorageArea;
19 using WebKit::WebStorageNamespace; 20 using WebKit::WebStorageNamespace;
21 using WebKit::WebString;
20 22
21 DOMStorageDispatcherHost::DOMStorageDispatcherHost( 23 DOMStorageDispatcherHost::DOMStorageDispatcherHost(
22 IPC::Message::Sender* message_sender, 24 IPC::Message::Sender* message_sender,
23 WebKitContext* webkit_context, 25 WebKitContext* webkit_context,
24 WebKitThread* webkit_thread) 26 WebKitThread* webkit_thread)
25 : webkit_context_(webkit_context), 27 : webkit_context_(webkit_context),
26 webkit_thread_(webkit_thread), 28 webkit_thread_(webkit_thread),
27 message_sender_(message_sender), 29 message_sender_(message_sender),
28 last_storage_area_id_(0), 30 last_storage_area_id_(0),
29 last_storage_namespace_id_(0), 31 last_storage_namespace_id_(0),
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop(); 276 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop();
275 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this, 277 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this,
276 &DOMStorageDispatcherHost::OnGetItem, 278 &DOMStorageDispatcherHost::OnGetItem,
277 storage_area_id, key, reply_msg)); 279 storage_area_id, key, reply_msg));
278 return; 280 return;
279 } 281 }
280 282
281 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); 283 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
282 WebStorageArea* storage_area = GetStorageArea(storage_area_id); 284 WebStorageArea* storage_area = GetStorageArea(storage_area_id);
283 CHECK(storage_area); // TODO(jorlow): Do better than this. 285 CHECK(storage_area); // TODO(jorlow): Do better than this.
284 WebKit::WebString value = storage_area->getItem(key); 286 WebString value = storage_area->getItem(key);
285 ViewHostMsg_DOMStorageGetItem::WriteReplyParams(reply_msg, (string16)value, 287 ViewHostMsg_DOMStorageGetItem::WriteReplyParams(reply_msg, (string16)value,
286 value.isNull()); 288 value.isNull());
287 Send(reply_msg); 289 Send(reply_msg);
288 } 290 }
289 291
290 void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id, 292 void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id,
291 const string16& key, 293 const string16& key,
292 const string16& value) { 294 const string16& value) {
293 DCHECK(!shutdown_); 295 DCHECK(!shutdown_);
294 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { 296 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 370
369 int64 DOMStorageDispatcherHost::AddStorageNamespace( 371 int64 DOMStorageDispatcherHost::AddStorageNamespace(
370 WebStorageNamespace* new_namespace) { 372 WebStorageNamespace* new_namespace) {
371 // Create a new ID and insert it into our map. 373 // Create a new ID and insert it into our map.
372 int64 new_namespace_id = ++last_storage_namespace_id_; 374 int64 new_namespace_id = ++last_storage_namespace_id_;
373 DCHECK(!GetStorageNamespace(new_namespace_id)); 375 DCHECK(!GetStorageNamespace(new_namespace_id));
374 storage_namespace_map_[new_namespace_id] = new_namespace; 376 storage_namespace_map_[new_namespace_id] = new_namespace;
375 return new_namespace_id; 377 return new_namespace_id;
376 } 378 }
377 379
378 string16 DOMStorageDispatcherHost::GetLocalStoragePath() { 380 WebString DOMStorageDispatcherHost::GetLocalStoragePath() {
379 // TODO(jorlow): Create a path based on the WebKitContext. 381 const FilePath& path = webkit_context_->data_path();
380 string16 path; 382 if (path.empty())
381 return path; 383 return WebString();
384 FilePath::StringType path_string = path.AppendASCII("localStorage").value();
385 return webkit_glue::FilePathStringToWebString(path_string);
382 } 386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698