2
* Copyright 2012 Google Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
// Author: lsong@google.com (Libo Song)
19
#ifndef PAGESPEED_KERNEL_BASE_SCOPED_PTR_H_
20
#define PAGESPEED_KERNEL_BASE_SCOPED_PTR_H_
23
// Chromium has moved scoped_ptr.h from base directory to base/memory.
24
// Thankfully, even older version we built against had it available in
25
// base/memory, just with the compatibility alias still available.
26
#include "base/memory/scoped_ptr.h"
28
// Note that this expression is carefully crafted so that someone compiling
29
// against PSOL libraries will compile using the Chromium version of
30
// scoped_array. This ifdef enables PageSpeed Insights to incrementally
31
// upgrade to a new version of Chromium that does not have scoped_array,
32
// but does have an array specialization for scoped_ptr.
33
#if defined(CHROMIUM_REVISION) && CHROMIUM_REVISION <= 194649
34
#define INSTAWEB_HAVE_SCOPED_ARRAY
38
namespace net_instaweb {
40
#ifdef INSTAWEB_HAVE_SCOPED_ARRAY
42
// TODO(jmarantz): Remove this once we update Chromium to a version
43
// greater than 194649, which will support specialization of arrays.
44
template<typename T> class scoped_array : public ::scoped_array<T> {
46
scoped_array() : ::scoped_array<T>() {}
47
explicit scoped_array(T* t) : ::scoped_array<T>(t) {}
52
template<typename T> class scoped_array : public scoped_ptr<T[]> {
54
scoped_array() : scoped_ptr<T[]>() {}
55
explicit scoped_array(T* t) : scoped_ptr<T[]>(t) {}
58
#endif // INSTAWEB_HAVE_SCOPED_ARRAY
60
} // namespace net_instaweb
62
#endif // PAGESPEED_KERNEL_BASE_SCOPED_PTR_H_