Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_TOOLS_FLIP_SERVER_MEM_CACHE_H_ | 5 #ifndef NET_TOOLS_FLIP_SERVER_MEM_CACHE_H_ |
| 6 #define NET_TOOLS_FLIP_SERVER_MEM_CACHE_H_ | 6 #define NET_TOOLS_FLIP_SERVER_MEM_CACHE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 int priority; | 107 int priority; |
| 108 bool transformed_header; | 108 bool transformed_header; |
| 109 size_t body_bytes_consumed; | 109 size_t body_bytes_consumed; |
| 110 uint32_t stream_id; | 110 uint32_t stream_id; |
| 111 uint32_t max_segment_size; | 111 uint32_t max_segment_size; |
| 112 size_t bytes_sent; | 112 size_t bytes_sent; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 class MemoryCache { | 115 class MemoryCache { |
| 116 public: | 116 public: |
| 117 typedef std::map<std::string, FileData*> Files; | 117 using Files = std::map<std::string, scoped_ptr<FileData>>; |
|
Ryan Hamilton
2015/12/28 15:06:30
Is there any reason to prefer using here to typede
Avi (use Gerrit)
2015/12/28 15:09:43
It's the new hotness as it's much easier to read a
Ryan Hamilton
2015/12/28 18:23:25
Definitely happy to follow the style guide, so +1
| |
| 118 | 118 |
| 119 public: | 119 public: |
| 120 MemoryCache(); | 120 MemoryCache(); |
| 121 virtual ~MemoryCache(); | 121 virtual ~MemoryCache(); |
| 122 | 122 |
| 123 void CloneFrom(const MemoryCache& mc); | |
| 124 | |
| 125 void AddFiles(); | 123 void AddFiles(); |
| 126 | 124 |
| 127 // virtual for unittests | 125 // virtual for unittests |
| 128 virtual void ReadToString(const char* filename, std::string* output); | 126 virtual void ReadToString(const char* filename, std::string* output); |
| 129 | 127 |
| 130 void ReadAndStoreFileContents(const char* filename); | 128 void ReadAndStoreFileContents(const char* filename); |
| 131 | 129 |
| 132 FileData* GetFileData(const std::string& filename); | 130 FileData* GetFileData(const std::string& filename); |
| 133 | 131 |
| 134 bool AssignFileData(const std::string& filename, MemCacheIter* mci); | 132 bool AssignFileData(const std::string& filename, MemCacheIter* mci); |
| 135 | 133 |
| 136 // For unittests | 134 // For unittests |
| 137 void InsertFile(const BalsaHeaders* headers, | 135 void InsertFile(const BalsaHeaders* headers, |
| 138 const std::string& filename, | 136 const std::string& filename, |
| 139 const std::string& body); | 137 const std::string& body); |
| 140 | 138 |
| 141 private: | 139 private: |
| 142 void InsertFile(FileData* file_data); | 140 void InsertFile(FileData* file_data); |
| 143 void ClearFiles(); | |
| 144 | 141 |
| 145 Files files_; | 142 Files files_; |
| 146 std::string cwd_; | 143 std::string cwd_; |
| 147 }; | 144 }; |
| 148 | 145 |
| 149 class NotifierInterface { | 146 class NotifierInterface { |
| 150 public: | 147 public: |
| 151 virtual ~NotifierInterface() {} | 148 virtual ~NotifierInterface() {} |
| 152 virtual void Notify() = 0; | 149 virtual void Notify() = 0; |
| 153 }; | 150 }; |
| 154 | 151 |
| 155 } // namespace net | 152 } // namespace net |
| 156 | 153 |
| 157 #endif // NET_TOOLS_FLIP_SERVER_MEM_CACHE_H_ | 154 #endif // NET_TOOLS_FLIP_SERVER_MEM_CACHE_H_ |
| OLD | NEW |