| OLD | NEW | 
|    1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2010 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/common/common_param_traits.h" |    5 #include "chrome/common/common_param_traits.h" | 
|    6  |    6  | 
|    7 #include "chrome/common/chrome_constants.h" |    7 #include "chrome/common/chrome_constants.h" | 
|    8 #include "gfx/rect.h" |    8 #include "gfx/rect.h" | 
|    9 #include "googleurl/src/gurl.h" |    9 #include "googleurl/src/gurl.h" | 
|   10 #ifndef EXCLUDE_SKIA_DEPENDENCIES |   10 #ifndef EXCLUDE_SKIA_DEPENDENCIES | 
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  140   m->WriteInt(p.height()); |  140   m->WriteInt(p.height()); | 
|  141 } |  141 } | 
|  142  |  142  | 
|  143 bool ParamTraits<gfx::Rect>::Read(const Message* m, void** iter, gfx::Rect* r) { |  143 bool ParamTraits<gfx::Rect>::Read(const Message* m, void** iter, gfx::Rect* r) { | 
|  144   int x, y, w, h; |  144   int x, y, w, h; | 
|  145   if (!m->ReadInt(iter, &x) || |  145   if (!m->ReadInt(iter, &x) || | 
|  146       !m->ReadInt(iter, &y) || |  146       !m->ReadInt(iter, &y) || | 
|  147       !m->ReadInt(iter, &w) || |  147       !m->ReadInt(iter, &w) || | 
|  148       !m->ReadInt(iter, &h)) |  148       !m->ReadInt(iter, &h)) | 
|  149     return false; |  149     return false; | 
|  150   if (x < 0 || y < 0 || x >= (INT_MAX - w) || y >= (INT_MAX - h) || |  | 
|  151       w < 0 || h < 0 || h >= ((INT_MAX / 16) / (w ? w : 1))) |  | 
|  152     return false; |  | 
|  153   r->set_x(x); |  150   r->set_x(x); | 
|  154   r->set_y(y); |  151   r->set_y(y); | 
|  155   r->set_width(w); |  152   r->set_width(w); | 
|  156   r->set_height(h); |  153   r->set_height(h); | 
|  157   return true; |  154   return true; | 
|  158 } |  155 } | 
|  159  |  156  | 
|  160 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::wstring* l) { |  157 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::wstring* l) { | 
|  161   l->append(StringPrintf(L"(%d, %d, %d, %d)", p.x(), p.y(), |  158   l->append(StringPrintf(L"(%d, %d, %d, %d)", p.x(), p.y(), | 
|  162                          p.width(), p.height())); |  159                          p.width(), p.height())); | 
|  163 } |  160 } | 
|  164  |  161  | 
|  165  |  162  | 
|  166 void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { |  163 void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { | 
|  167   m->WriteInt(p.width()); |  164   m->WriteInt(p.width()); | 
|  168   m->WriteInt(p.height()); |  165   m->WriteInt(p.height()); | 
|  169 } |  166 } | 
|  170  |  167  | 
|  171 bool ParamTraits<gfx::Size>::Read(const Message* m, void** iter, gfx::Size* r) { |  168 bool ParamTraits<gfx::Size>::Read(const Message* m, void** iter, gfx::Size* r) { | 
|  172   int w, h; |  169   int w, h; | 
|  173   if (!m->ReadInt(iter, &w) || |  170   if (!m->ReadInt(iter, &w) || | 
|  174       !m->ReadInt(iter, &h)) |  171       !m->ReadInt(iter, &h)) | 
|  175     return false; |  172     return false; | 
|  176   if (w < 0 || h < 0 || h >= ((INT_MAX / 16) / (w ? w : 1))) |  | 
|  177     return false; |  | 
|  178   r->set_width(w); |  173   r->set_width(w); | 
|  179   r->set_height(h); |  174   r->set_height(h); | 
|  180   return true; |  175   return true; | 
|  181 } |  176 } | 
|  182  |  177  | 
|  183 void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::wstring* l) { |  178 void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::wstring* l) { | 
|  184   l->append(StringPrintf(L"(%d, %d)", p.width(), p.height())); |  179   l->append(StringPrintf(L"(%d, %d)", p.width(), p.height())); | 
|  185 } |  180 } | 
|  186  |  181  | 
|  187 void ParamTraits<ContentSettings>::Write( |  182 void ParamTraits<ContentSettings>::Write( | 
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  301           L"%.6f %.6f %.6f ", |  296           L"%.6f %.6f %.6f ", | 
|  302           p.latitude, p.longitude, p.accuracy, p.altitude, |  297           p.latitude, p.longitude, p.accuracy, p.altitude, | 
|  303           p.altitude_accuracy, p.speed, p.heading)); |  298           p.altitude_accuracy, p.speed, p.heading)); | 
|  304   LogParam(p.timestamp, l); |  299   LogParam(p.timestamp, l); | 
|  305   l->append(L" "); |  300   l->append(L" "); | 
|  306   l->append(p.error_message); |  301   l->append(p.error_message); | 
|  307   LogParam(p.error_code, l); |  302   LogParam(p.error_code, l); | 
|  308 } |  303 } | 
|  309  |  304  | 
|  310 }  // namespace IPC |  305 }  // namespace IPC | 
| OLD | NEW |