| OLD | NEW |
| 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 5 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 | 11 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 void BrowserActionDragData::WriteToPickle( | 66 void BrowserActionDragData::WriteToPickle( |
| 67 Profile* profile, Pickle* pickle) const { | 67 Profile* profile, Pickle* pickle) const { |
| 68 pickle->WriteBytes(&profile, sizeof(profile)); | 68 pickle->WriteBytes(&profile, sizeof(profile)); |
| 69 pickle->WriteString(id_); | 69 pickle->WriteString(id_); |
| 70 pickle->WriteSize(index_); | 70 pickle->WriteSize(index_); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool BrowserActionDragData::ReadFromPickle(Pickle* pickle) { | 73 bool BrowserActionDragData::ReadFromPickle(Pickle* pickle) { |
| 74 void* data_iterator = NULL; | 74 PickleIterator data_iterator(*pickle); |
| 75 | 75 |
| 76 const char* tmp; | 76 const char* tmp; |
| 77 if (!pickle->ReadBytes(&data_iterator, &tmp, sizeof(profile_))) | 77 if (!pickle->ReadBytes(&data_iterator, &tmp, sizeof(profile_))) |
| 78 return false; | 78 return false; |
| 79 memcpy(&profile_, tmp, sizeof(profile_)); | 79 memcpy(&profile_, tmp, sizeof(profile_)); |
| 80 | 80 |
| 81 if (!pickle->ReadString(&data_iterator, &id_)) | 81 if (!pickle->ReadString(&data_iterator, &id_)) |
| 82 return false; | 82 return false; |
| 83 | 83 |
| 84 if (!pickle->ReadSize(&data_iterator, &index_)) | 84 if (!pickle->ReadSize(&data_iterator, &index_)) |
| 85 return false; | 85 return false; |
| 86 | 86 |
| 87 return true; | 87 return true; |
| 88 } | 88 } |
| OLD | NEW |