1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35

media / base / cross_origin_data_source.h [blame]

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_BASE_CROSS_ORIGIN_DATA_SOURCE_H_
#define MEDIA_BASE_CROSS_ORIGIN_DATA_SOURCE_H_

#include "media/base/data_source.h"
#include "media/base/media_export.h"

namespace media {

// This represents any type of DataSource which MAY make cross origin requests,
// as opposed to something like the "MemoryDataSource" which is only reading
// from an already-allocated block of data, and can't be cross origin at all.
class MEDIA_EXPORT CrossOriginDataSource : public DataSource {
 public:
  // https://html.spec.whatwg.org/#cors-cross-origin
  // This must be called after the response arrives.
  virtual bool IsCorsCrossOrigin() const = 0;

  // Returns true if the response includes an Access-Control-Allow-Origin
  // header (that is not "null").
  virtual bool HasAccessControl() const = 0;

  virtual const std::string& GetMimeType() const = 0;

  // Allows the data source to perform any additional initialization steps.
  // This should always be called after constructing, and before other use.
  virtual void Initialize(base::OnceCallback<void(bool)> init_cb) = 0;
};

}  // namespace media

#endif  // MEDIA_BASE_CROSS_ORIGIN_DATA_SOURCE_H_