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

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

Issue 174484: Add a nullable string16 class to base. It combines a string16 + a null param... (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/nullable_string16.h"
7 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.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 #include "webkit/glue/webkit_glue.h"
18 18
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { 256 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
257 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop(); 257 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop();
258 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this, 258 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this,
259 &DOMStorageDispatcherHost::OnKey, storage_area_id, index, reply_msg)); 259 &DOMStorageDispatcherHost::OnKey, storage_area_id, index, reply_msg));
260 return; 260 return;
261 } 261 }
262 262
263 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); 263 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
264 WebStorageArea* storage_area = GetStorageArea(storage_area_id); 264 WebStorageArea* storage_area = GetStorageArea(storage_area_id);
265 CHECK(storage_area); // TODO(jorlow): Do better than this. 265 CHECK(storage_area); // TODO(jorlow): Do better than this.
266 WebString key = storage_area->key(index); 266 const NullableString16& key = storage_area->key(index);
267 ViewHostMsg_DOMStorageKey::WriteReplyParams(reply_msg, (string16)key, 267 ViewHostMsg_DOMStorageKey::WriteReplyParams(reply_msg, key);
268 key.isNull());
269 Send(reply_msg); 268 Send(reply_msg);
270 } 269 }
271 270
272 void DOMStorageDispatcherHost::OnGetItem(int64 storage_area_id, 271 void DOMStorageDispatcherHost::OnGetItem(int64 storage_area_id,
273 const string16& key, 272 const string16& key,
274 IPC::Message* reply_msg) { 273 IPC::Message* reply_msg) {
275 DCHECK(!shutdown_); 274 DCHECK(!shutdown_);
276 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { 275 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
277 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop(); 276 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop();
278 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this, 277 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this,
279 &DOMStorageDispatcherHost::OnGetItem, 278 &DOMStorageDispatcherHost::OnGetItem,
280 storage_area_id, key, reply_msg)); 279 storage_area_id, key, reply_msg));
281 return; 280 return;
282 } 281 }
283 282
284 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); 283 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
285 WebStorageArea* storage_area = GetStorageArea(storage_area_id); 284 WebStorageArea* storage_area = GetStorageArea(storage_area_id);
286 CHECK(storage_area); // TODO(jorlow): Do better than this. 285 CHECK(storage_area); // TODO(jorlow): Do better than this.
287 WebString value = storage_area->getItem(key); 286 const NullableString16& value = storage_area->getItem(key);
288 ViewHostMsg_DOMStorageGetItem::WriteReplyParams(reply_msg, (string16)value, 287 ViewHostMsg_DOMStorageGetItem::WriteReplyParams(reply_msg, value);
289 value.isNull());
290 Send(reply_msg); 288 Send(reply_msg);
291 } 289 }
292 290
293 void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id, 291 void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id,
294 const string16& key, 292 const string16& key,
295 const string16& value) { 293 const string16& value) {
296 DCHECK(!shutdown_); 294 DCHECK(!shutdown_);
297 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { 295 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
298 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop(); 296 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop();
299 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this, 297 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 return new_namespace_id; 376 return new_namespace_id;
379 } 377 }
380 378
381 WebString DOMStorageDispatcherHost::GetLocalStoragePath() { 379 WebString DOMStorageDispatcherHost::GetLocalStoragePath() {
382 const FilePath& path = webkit_context_->data_path(); 380 const FilePath& path = webkit_context_->data_path();
383 if (path.empty()) 381 if (path.empty())
384 return WebString(); 382 return WebString();
385 FilePath::StringType path_string = path.AppendASCII("localStorage").value(); 383 FilePath::StringType path_string = path.AppendASCII("localStorage").value();
386 return webkit_glue::FilePathStringToWebString(path_string); 384 return webkit_glue::FilePathStringToWebString(path_string);
387 } 385 }
OLDNEW
« no previous file with comments | « chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h ('k') | chrome/common/render_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698