Skip to content

Commit

Permalink
Remove dependency on base::SequencedWorkerPool
Browse files Browse the repository at this point in the history
ImageFetcher only require that all the task be eventually executed
on any thread, in any order so it does no need to depends on the
implementation class base::SequencedWorkerPool but can work with
just the interface base::TaskRunner.

BUG=None

Review URL: https://codereview.chromium.org/808833004

Cr-Commit-Position: refs/heads/master@{#308825}
  • Loading branch information
sdefresne authored and Commit bot committed Dec 17, 2014
1 parent 9ab406f commit 00cc5dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions ios/chrome/browser/net/image_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GURL;
@class NSData;

namespace base {
class SequencedWorkerPool;
class TaskRunner;
}

namespace net {
Expand All @@ -40,9 +40,8 @@ using ImageFetchedCallback =
// An instance of this class can download a number of images at the same time.
class ImageFetcher : public net::URLFetcherDelegate {
public:
// The WorkerPool is used to eventually decode the image.
explicit ImageFetcher(
const scoped_refptr<base::SequencedWorkerPool>& decoding_pool);
// The TaskRunner is used to eventually decode the image.
explicit ImageFetcher(const scoped_refptr<base::TaskRunner>& task_runner);
~ImageFetcher() override;

// Start downloading the image at the given |url|. The |callback| will be
Expand Down Expand Up @@ -86,8 +85,8 @@ class ImageFetcher : public net::URLFetcherDelegate {
// during WebP decoding.
base::WeakPtrFactory<ImageFetcher> weak_factory_;

// The pool used to decode images if necessary.
const scoped_refptr<base::SequencedWorkerPool> decoding_pool_;
// The task runner used to decode images if necessary.
const scoped_refptr<base::TaskRunner> task_runner_;
};

} // namespace image_fetcher
Expand Down
11 changes: 5 additions & 6 deletions ios/chrome/browser/net/image_fetcher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/mac/scoped_nsobject.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/task_runner.h"
#include "ios/web/public/web_thread.h"
#include "ios/web/public/webp_decoder.h"
#include "net/base/load_flags.h"
Expand Down Expand Up @@ -60,12 +60,11 @@ void OnDataDecoded(NSData* data) override {

namespace image_fetcher {

ImageFetcher::ImageFetcher(
const scoped_refptr<base::SequencedWorkerPool>& decoding_pool)
ImageFetcher::ImageFetcher(const scoped_refptr<base::TaskRunner>& task_runner)
: request_context_getter_(nullptr),
weak_factory_(this),
decoding_pool_(decoding_pool) {
DCHECK(decoding_pool_.get());
task_runner_(task_runner) {
DCHECK(task_runner_.get());
}

ImageFetcher::~ImageFetcher() {
Expand Down Expand Up @@ -148,7 +147,7 @@ void OnDataDecoded(NSData* data) override {
std::string mime_type;
fetcher->GetResponseHeaders()->GetMimeType(&mime_type);
if (mime_type == kWEBPMimeType) {
base::PostTaskAndReplyWithResult(decoding_pool_.get(),
base::PostTaskAndReplyWithResult(task_runner_.get(),
FROM_HERE,
base::Bind(&DecodeWebpImage, data),
base::Bind(&ImageFetcher::RunCallback,
Expand Down

0 comments on commit 00cc5dd

Please sign in to comment.