article_distillation_update.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_DISTILLATION_UPDATE_H_
  5. #define COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_DISTILLATION_UPDATE_H_
  6. #include <stddef.h>
  7. #include <vector>
  8. #include "base/memory/ref_counted.h"
  9. #include "components/dom_distiller/core/proto/distilled_page.pb.h"
  10. namespace dom_distiller {
  11. // Update about an article that is currently under distillation.
  12. class ArticleDistillationUpdate {
  13. public:
  14. typedef base::RefCountedData<DistilledPageProto> RefCountedPageProto;
  15. ArticleDistillationUpdate(
  16. const std::vector<scoped_refptr<RefCountedPageProto>>& pages,
  17. bool has_next_page,
  18. bool has_prev_page);
  19. ArticleDistillationUpdate(const ArticleDistillationUpdate& other);
  20. ~ArticleDistillationUpdate();
  21. // Returns the distilled page at |index|.
  22. const DistilledPageProto& GetDistilledPage(size_t index) const;
  23. // Returns the size of distilled pages in this update.
  24. size_t GetPagesSize() const { return pages_.size(); }
  25. // Returns true, if article has a next page that is currently under
  26. // distillation and that is not part of the distilled pages included in this
  27. // update.
  28. bool HasNextPage() const { return has_next_page_; }
  29. // Returns true if article has a previous page that is currently under
  30. // distillation and that is not part of the distilled pages included in this
  31. // update.
  32. bool HasPrevPage() const { return has_prev_page_; }
  33. private:
  34. bool has_next_page_;
  35. bool has_prev_page_;
  36. // Currently available pages.
  37. std::vector<scoped_refptr<RefCountedPageProto>> pages_;
  38. };
  39. } // namespace dom_distiller
  40. #endif // COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_DISTILLATION_UPDATE_H_