OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/disk_cache/flash/internal_entry.h" | 5 #include "net/disk_cache/flash/internal_entry.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "net/base/completion_callback.h" | 8 #include "net/base/completion_callback.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 return entry_->WriteData(++index, offset, buf, buf_len); | 64 return entry_->WriteData(++index, offset, buf, buf_len); |
65 } | 65 } |
66 | 66 |
67 void InternalEntry::Close() { | 67 void InternalEntry::Close() { |
68 entry_->Close(); | 68 entry_->Close(); |
69 } | 69 } |
70 | 70 |
71 bool InternalEntry::WriteKey(LogStoreEntry* entry, const std::string& key) { | 71 bool InternalEntry::WriteKey(LogStoreEntry* entry, const std::string& key) { |
72 int key_size = static_cast<int>(key.size()); | 72 int key_size = static_cast<int>(key.size()); |
73 scoped_refptr<IOBuffer> key_buf(new StringIOBuffer(key)); | 73 scoped_refptr<IOBuffer> key_buf(new StringIOBuffer(key)); |
74 return entry->WriteData(0, 0, key_buf, key_size) == key_size; | 74 return entry->WriteData(0, 0, key_buf.get(), key_size) == key_size; |
75 } | 75 } |
76 | 76 |
77 bool InternalEntry::ReadKey(LogStoreEntry* entry, std::string* key) { | 77 bool InternalEntry::ReadKey(LogStoreEntry* entry, std::string* key) { |
78 int key_size = entry->GetDataSize(0); | 78 int key_size = entry->GetDataSize(0); |
79 scoped_refptr<net::IOBuffer> key_buf(new net::IOBuffer(key_size)); | 79 scoped_refptr<net::IOBuffer> key_buf(new net::IOBuffer(key_size)); |
80 if (entry->ReadData(0, 0, key_buf, key_size) != key_size) | 80 if (entry->ReadData(0, 0, key_buf.get(), key_size) != key_size) |
81 return false; | 81 return false; |
82 key->assign(key_buf->data(), key_size); | 82 key->assign(key_buf->data(), key_size); |
83 return true; | 83 return true; |
84 } | 84 } |
85 | 85 |
86 } // namespace disk_cache | 86 } // namespace disk_cache |
OLD | NEW |