| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "webkit/glue/image_resource_fetcher.h" | 5 #include "webkit/glue/image_resource_fetcher.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "gfx/size.h" | 8 #include "gfx/size.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 10 #include "webkit/glue/image_decoder.h" | 10 #include "webkit/glue/image_decoder.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 SkBitmap bitmap; | 40 SkBitmap bitmap; |
| 41 if (!response.isNull() && response.httpStatusCode() == 200) { | 41 if (!response.isNull() && response.httpStatusCode() == 200) { |
| 42 // Request succeeded, try to convert it to an image. | 42 // Request succeeded, try to convert it to an image. |
| 43 ImageDecoder decoder(gfx::Size(image_size_, image_size_)); | 43 ImageDecoder decoder(gfx::Size(image_size_, image_size_)); |
| 44 bitmap = decoder.Decode( | 44 bitmap = decoder.Decode( |
| 45 reinterpret_cast<const unsigned char*>(data.data()), data.size()); | 45 reinterpret_cast<const unsigned char*>(data.data()), data.size()); |
| 46 } // else case: | 46 } // else case: |
| 47 // If we get here, it means no image from server or couldn't decode the | 47 // If we get here, it means no image from server or couldn't decode the |
| 48 // response as an image. The delegate will see a null image, indicating | 48 // response as an image. The delegate will see a null image, indicating |
| 49 // that an error occurred. | 49 // that an error occurred. |
| 50 callback_->Run(this, bitmap); | 50 |
| 51 callback_.reset(); | 51 // Take care to clear callback_ before running the callback as it may lead to |
| 52 // our destruction. |
| 53 scoped_ptr<Callback> callback; |
| 54 callback.swap(callback_); |
| 55 callback->Run(this, bitmap); |
| 52 } | 56 } |
| 53 | 57 |
| 54 } // namespace webkit_glue | 58 } // namespace webkit_glue |
| OLD | NEW |