Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Unified Diff: components/image_fetcher/image_data_fetcher.h

Issue 2045233002: Split the code for fetching images and for decoding images into two separate classes. This will all… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make ~DecodeImageRequest() final Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/image_fetcher/image_data_fetcher.h
diff --git a/components/image_fetcher/image_data_fetcher.h b/components/image_fetcher/image_data_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..5cfea41f62fa2c20a157f46c2c3ffd0865a0199e
--- /dev/null
+++ b/components/image_fetcher/image_data_fetcher.h
@@ -0,0 +1,54 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_
+#define COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_
+
+#include <map>
+#include <memory>
+
+#include "base/macros.h"
+#include "net/url_request/url_fetcher.h"
+#include "net/url_request/url_fetcher_delegate.h"
+#include "net/url_request/url_request.h"
+#include "url/gurl.h"
+
+namespace net {
+class URLRequestContextGetter;
+} // namespace net
+
+namespace image_fetcher {
+
+class ImageDataFetcher {
+ public:
+ using ImageDataFetcherCallback =
+ base::Callback<void(const std::string& image_data)>;
+
+ ImageDataFetcher(net::URLRequestContextGetter* url_request_context_getter);
+ ~ImageDataFetcher();
+
+ // Fetches the raw image bytes from the given |image_url| and calls the given
+ // |callback|. The callback is run even if fetching the URL fails. In case
+ // of an error an empty string is passed to the callback.
+ void FetchImageURL(const GURL& image_url,
Marc Treib 2016/06/10 08:32:37 FetchImageData?
markusheintz_ 2016/06/10 09:43:14 Already done. Sorry I forgot last night and quickl
+ const ImageDataFetcherCallback& callback);
+
+ private:
+ class ImageDataFetcherRequest;
Marc Treib 2016/06/10 08:32:37 optional: Since this is a private inner class, you
markusheintz_ 2016/06/10 09:43:14 Acknowledged.
+
+ // Removes the ImageDataFetcherRequest for the given |image_url| from the
+ // internal request queue.
+ void RemoveImageDataFetcherRequest(const GURL& image_url);
+
+ // All active image url requests.
+ std::map<const GURL, std::unique_ptr<ImageDataFetcherRequest>> request_queue_;
Marc Treib 2016/06/10 08:32:37 Just requests_, or maybe pending_requests_? It's n
markusheintz_ 2016/06/10 09:43:14 I chose pending_requests_.
+
+ net::URLRequestContextGetter* url_request_context_getter_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImageDataFetcher);
+};
+
+} // namespace image_fetcher
+
+#endif // COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698